<?php
namespace App\Controller;
use App\ClassTheatre\aside\asidesUrlPagination;
use App\ClassTheatre\asides;
use App\ClassTheatre\TheatreController;
use App\Service\Abonnements\Abonnements;
use App\Service\Functions;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use TheatreCore\Entity\Bigregions;
use TheatreCore\Entity\Classifications;
use TheatreCore\Entity\Contacts;
use TheatreCore\Entity\Files;
use TheatreCore\Entity\Multimedias;
use TheatreCore\Entity\News;
use TheatreCore\Entity\Persons;
use TheatreCore\Entity\Regions;
use TheatreCore\Entity\Spectacles;
use TheatreCore\Entity\Typesstructures;
use TheatreCore\Form\Type\RelationsType;
class SpectaclesController extends TheatreController
{
// l'objet spectacles
protected $spectacles;
// par page
protected $perPage = 20;
// version de la carte
protected $carte_version = 'svg';
// {{{ _construct()
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator, TokenStorageInterface $tokenStorage, Abonnements $abonnements)
{
parent::__construct($translator, $tokenStorage);
$this->context['controller'] = $this->view->controller = 'spectacles';
$this->em = $em;
$this->spectacles = $em->getRepository(Spectacles::class);
$this->getCarteVersion();
$this->serviceAbonnements = $abonnements;
}
// {{{ region_common()
/**
* @Route("/spectacles/", name="spectacles_index")
*
* region_common
*
*/
public function action_index()
{
$this->context['action'] = 'view';
// pager & mois pour liste deroulante
// include PATH_LIBS.'/Functions/Months.php';
// trucs commun
// include PATH_APP.$module.'/controllers/Spectacles/commun.inc.php';
$form = $this->setCommonSearch()->getForm();
$this->context['view']->formAsideSearch = $form->createView();
// page de provenance
$this->view->from_page = '/spectacles/';
// instancier un objet spectacles
// nb total de spectacle
$sql_count = 'SELECT COUNT(DISTINCT('.$this->spectacles->__idtable.')) FROM '.$this->spectacles->__table.' WHERE publish=1';
$this->view->nb_total = $this->spectacles->queryOne($sql_count);
//menu pour l'aside Spéctacles à venir
$spectacles_a_venir = array(
array(
'name' => 'Dans les 7 prochains jours',
'key_day' => '7',
),
array(
'name' => 'Dans les 30 prochains jours',
'key_day' => '30',
),
array(
'name' => 'Dans les 3 prochains mois',
'key_day' => '90',
),
array(
'name' => 'Dans les 12 prochains mois',
'key_day' => '365',
)
);
$day_spectacles = 365; $day_all = false;
if(!empty($_REQUEST['d'])){
if(in_array($_REQUEST['d'], array_column($spectacles_a_venir, 'key_day'))){
$day_spectacles = $_REQUEST['d'];
if(!is_numeric($day_spectacles)){
$day_all = true;
}
}
}
$this->view->jours_affiche_all = $day_all;
$spectacles_voir = array(
array(
'name' => 'Tous les spectacles',
'key_filtre' => '', // TODO: fixe v2
'action' => 'view',
),
array(
'name' => 'Tous les spectacles avec vidéos',
'key_filtre' => 'theatre/affiche-videos/',
'action' => 'affiche-videos'
),
array(
'name' => 'Tous les spectacles avec audios',
'url' => '/audios/spectacles/type/prochains/',
'action' => 'affiche-audios'
),
array(
'name' => 'Premières',
'url' => '/premieres/mondiales',
'action' => 'premieres'
),
);
$filtre_spectacles = 'view';
if(in_array($this->context['action'], array_column($spectacles_voir, 'action'))){
$filtre_spectacles = $this->context['action'];
}
$this->view->spectacle_avenir_jour = $day_spectacles;
$params_days_numeric = array();
if(is_numeric($day_spectacles)){
$params_days_numeric = array(
'prochains' => $day_spectacles
);
}
$special_params = array(
'prochains' => $day_spectacles
);
//nombre total de spectacle a venir
$nombreprochainspectacle = $this->spectacles->countSpectacles($params_days_numeric);
//les pages pour les spectacles à l'affiche
$this->perPage = $pagerOptions['perPage'] = 30;
$pagerOptions['totalItems'] = $nombreprochainspectacle;
// pagination
// require PATH_LIBS.'Pager/Pagersimple.php';
// $this->view->pagination = $paged_data = pagerSimple($pagerOptions);
$this->view->pagination = $this->getPagination($nombreprochainspectacle);
$this->view->pagination['spectacle'] = true;
// require_once PATH_ADMIN."app/common/helpers/aside/asidesUrlPagination.php";
$urlpagination = new asidesUrlPagination(
'/spectacles/generate_params',
array(
'day' => $day_spectacles,
),
$this->context
);
$this->view->pagination['url_custom'] = $urlpagination->url_pagination();
$paged_data['from'] = 10;
// les prochains spectacles
$params_sql_prochains = array(
'params' => array(
'limit' => array($this->getLimitStart(),$this->perPage),
'where' => ' AND s.idspectaclegenre=1'
),
'special' => $special_params,
);
$prochains_spectacles = $this->spectacles->getListSpectacles(
$params_sql_prochains,
array('vignette' => array(
'width'=>100,'height'=>100,'direction'=>'crop','fleche'=>'moyen'
)),
false,
array(
'allauthors' => true,
'carrer_couleurs' => true
)
);
// trier les spectacles en france et à l'étranger
foreach($prochains_spectacles as $key=>$val) {
$val['footer_contact'] = true;
$idspectacle = $val['idspectacle'];
if(isset($val['allpersons']) && sizeof($val['allpersons']) >= 2){
$allpersons = array();
foreach($val['allpersons'] AS $k => $v){
unset($v['nopunct']);
$allpersons[$k] = $v;
if(sizeof($allpersons) == 2) break;
}
$val['allpersons'] = $this->spectacles->noPunct($allpersons);
}
$prochains_spectacles[$key] = $val;
// France
// if($val['country']=='FR') {
// $spec[$idspectacle] = $val;
// } else {
// $spec_etranger[$idspectacle] = $val;
// }
}
// envoi au template
if (!empty($prochains_spectacles)){
$this->view->spectacles = $prochains_spectacles;
}
if (!empty($spec_etranger)){
$this->view->spectacles_etranger = $spec_etranger;
}
$this->view->default = true;
// options générales
// require_once PATH_LIBS.'Options/Theatre_options.php';
// $th_options = new Theatre_options($module);
// Gestion du cache
// require_once PATH_LIBS.'Cache/Theatre_cache.php';
// les spectacles les plus consultes généré toutes les nuits
$statsname = 'spectacleslesplusvus';
// $cf = $th_options->getOptions('stats.'.$statsname);
$cache = array();
// les options
// $cache['options'] = array(
// 'id' => $statsname.'_'.$GLOBALS['lng'],
// 'group' => $this->context['module'],
// 'cacheDir' => $cf['cacheDir'],
// 'lifeTime' => $cf['lifeTime'],
// 'fileNameProtection'=>false
// );
// $cache[$statsname] = new Theatre_cache($cache['options']);
// cache
// if (USE_CACHE && !$calculwget && $cache['data'] = $cache[$statsname]->get()) {
// // on récupère les données du cache
// $plus_vus = unserialize($cache['data']);
// } else {
/* todo ne pas push a remettre pour la production */
// $statscumul = Theatre::factory('statscumul');
// $plus_vus = $statscumul->spectaclesLesPlusVus($cf['max_items'], $module, $lng, $cf['facteur']);
// sauvegarde le cache
//$cache[$statsname]->save(serialize($plus_vus));
// }
// envoi les stats à la vue
// $this->view->plus_vus_count = count($plus_vus);
// $this->view->plus_vus = $plus_vus;
//recuperer le contenu multimedia
$multimedias = $this->em->getRepository(Multimedias::class);
//recuperer la page
$classification = $this->em->getRepository(Classifications::class);
// classe images
// require_once PATH_LIBS.'Images/Images.php';
// $images = new Images();
// $images->setVignetteFormat(array('width'=>93,'height'=>70,'direction'=>'crop','fleche'=>'moyen'));
// situation et titre meta
$this->view->locate = array(0 => 'Spectacles');
$this->view->title_page = 'Les spectacles de théâtre contemporain en France et à l\'étranger';
$this->view->rub_courante = 'spectacles';
// jquery
$this->view->jquery_cal = 'datepicker';
$this->view->jquery_flash = true;
$this->context['view']->use_addthis = true;
$this->context['view']->is_carte_svg = true;
$this->context['view']->js_more['raphael-min-js'] = 'raphaeljs/raphael-min.js';
$this->context['view']->js_more['raphael-svg-import'] = 'raphaeljs/raphael-svg-import.js';
// Placeholder du champ de recherche du nom de spectacles
// $form->addElement('text', 'title', '', array('id'=>'title','placeholder' => 'Un nom de spectacle'));
//On affiche la publicité google
$asides_publicite = new asides();
asides::setEntityManager($this->em);
asides::loadaside('Publicite')->addGoogle($asides_publicite, $this->serviceAbonnements);
$this->context['view']->asides_publicite = $asides_publicite->view($this->context['view']);
$asides = new asides();
$asides->load(['url_lists,a_laffiche' => array(
'exec' => array(
'htmlstart' => true
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $spectacles_voir,
'url' => '/spectacles/key_filtre',
'params' => array(
'activate' => $filtre_spectacles
)
),
'title' => html_entity_decode('À l\'affiche')
)]);
$asides->load(['url_lists' => array(
'exec' => array(
'alone' => false
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $spectacles_a_venir,
'url' => '/spectacles/?d=key_day',
'params' => array(
'activate' => $day_spectacles
)
),
'title' => html_entity_decode('Recherche par période')
)]);
$asides->load(['recherche_par_periode' => array(
'exec' => array(
'htmlend' => true
),
'action' => '/spectacles/theatre/recherche'
)]);
//$asides->load('spectacles_rechercher_nom');
$asides->load(['url_lists_alone,tn_cdn_sn' => array(
'php' => [
'method' => 'tn_cdn_sn',
'url' => '/key_controller/liste/structures/generate_params',
'params' => array(
'activate' => (isset($this->context['view']->idtypestructure)) ? $this->context['view']->idtypestructure : 'ALL',
'url_custom' => ['ALL' => '/spectacles/']
),
'structure' => array(
'area' => $this->context['view']->area ?? null,
'type' => $this->context['view']->type_spectacle ?? null,
'structure_classic' => array(
'd' => 'v_days',
'type' => 'v_type',
's' => 'v_saison',
'y' => 'v_year',
'dateend' => 'v_dateend',
'datestart' => 'v_datestart',
'idtypestructure' => 'key_structure'
)
)
],
'title' => 'Voir dans'
)]);
$asides->load(['common_carte' => array(
'url' => '/spectacles/theatre/region/area/get_id?carte_version=svg'
)]);
$asides->load('common_carrer_informations');
asides::setEntityManager($this->em);
asides::loadaside('Publicite')->addWithNational($asides); //$this->area
$asides->load(['common_participer'=>array(
'php' => array(
'method' => 'asidesUrlLists_Ajoutez'
)
)]);
$this->context['view']->aside = $asides->view($this->context['view']);
return $this->view('spectacles/view.html.twig');
}
// }}}
// {{{ region_common()
/** region_common
*
*/
public function region_common(){
$nb_day_default = 90;
$this->getCommonSearch(array(
'nb_days' => $nb_day_default,
));
$choix_type = array('SN','TN','CDN','AP');
$this->context['idtypestructure'] = null;
if(!empty($_REQUEST['idtypestructure']) && in_array($_REQUEST['idtypestructure'], $choix_type)) {
$this->context['idtypestructure'] = filter_var($_REQUEST['idtypestructure'], FILTER_SANITIZE_STRING);
}
$this->context['view']->menu_structures = array(
'region' => array('url'=> '/spectacles/theatre/region/generate_params','name'=> 'Tous les spectacles','id'=>'region'),
'region-videos' => array('url'=> '/spectacles/theatre/region-videos/generate_params','name'=> 'Spectacles avec vidéos','id'=>'region-videos'),
'textes-videos' => array('url'=> '/textes/editions/auteurs-spectacles/generate_params','name'=> 'Les textes par leurs auteurs','id'=>'textes-videos'),
'premieres' => array('url' => '/premieres/regions/area/{p_area}', 'name' => 'Premières'),
// 'region-coprod' => array('url'=> '/spectacles/theatre/region-coprod/generate_params','name'=> 'En tournée','id'=>'region-coprod'),
// 'region-evenements' => array('url'=> '/spectacles/theatre/region-evenements','name'=> 'Évènements','id'=>'region-evenements'),
// 'region-programmes' => array('url'=> '/contacts/archives/programmes/area/'.$this->context['params']['area'],'name'=> 'Programmes en PDF','id'=>'region-programmes'),
);
$this->context['region']['days_array'] = array(
7 => array('name' => 'Dans les 7 prochains jours', 'key_day' => '7'),
30 => array('name' => 'Dans les 30 prochains jours', 'key_day' => '30'),
90 => array('name' => 'Dans les 3 prochains mois', 'key_day' => '90'),
365 => array('name' => 'Dans les 12 prochains mois','key_day' => '365')
);
if(!in_array($this->context['view']->days, array_column($this->context['region']['days_array'], 'key_day'))){
$this->context['view']->days = $nb_day_default;
}
$this->context['view']->nb_jour = $this->context['view']->days;
if($this->context['params']['area'] == 43){
$this->context['view']->menu_structures['region-soutien'] = array('url'=> '/spectacles/theatre/region-soutien','name'=> 'Avec le soutien de la région','id'=>'region-soutien');
}
$params = $this->context['params'];
$city = null;
if(array_key_exists('city', $params) || (isset($_REQUEST['city']) && !empty($_REQUEST['city']))) {
$value = (array_key_exists('city', $params)) ? $params['city'] : $_REQUEST['city'];
$this->context['view']->city = $city = filter_var($value);
}
// regions
$regions = $this->em->getRepository(Bigregions::class);
// $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'));
$area = null;
$params = $this->context['params'];
if(array_key_exists('area',$params) && (is_numeric($params['area']) || strlen($params['area'])<3)) {
$area = $params['area'];
}
if($regions->my_is_int($area)) {
$sql_area = $regions->getZipCode($area, 'contacts');
} else {
$country_name = $this->spectacles->getNameCountry($area);
$this->context['view']->other_country = true;
$sql_area = ' contacts.country=\''.$this->spectacles->escape($area).'\' ';
}
$this->context['sql_area'] = $sql_area;
// si pas de région ou de ville
if (empty($area) && empty($city)) {
return $this->redirect('/spectacles/');
}
// nom de la région et code
if(!empty($area)) {
if(!empty($country_name)) {
$this->context['view']->country_name = $country_name;
} else {
$this->context['view']->region_name = $regions->getRegionName($area);
}
$this->context['view']->area = $area;
//SQL : si region, recherche des spectacles dans la région ou le pays
$this->context['where_zone'] = $sql_area;
if (!$sql_area) {
return $this->redirectToRoute("spectacles_region_videos");
}
}
// si ville, recherche des spectacles dans la ville
if(!empty($city)) {
$this->context['where_zone'] = ' contacts.city LIKE \'%'.$this->spectacles->escape($city).'%\' ';
}
$this->context['region']['vignette'] = array('width'=>100,'height'=>100,'direction'=>'crop');
$this->context['view']->insert_block = 'spectacles/region.choix.inc.html';
// trouver le spectacle avec la date la plus éloignée ou les dates
$sql = 'SELECT MAX(sc.date) FROM schedules sc, contacts
WHERE sc.idcontact=contacts.idcontact AND '.$sql_area.' AND sc.date>=\''.date('Y-m-d').'\'';
$this->context['view']->datemax = $this->spectacles->queryOne($sql);
$this->context['sql_date'] = null;
if(!empty($this->context['view']->datestart) && !empty($this->context['view']->dateend)) {
// les dates doivent être entre hier et le max
if($this->context['view']->datestart<date('Y-m-d')) {
$this->context['view']->datestart = date('Y-m-d');
}
if($this->context['view']->dateend>$this->context['view']->datemax) {
$this->context['view']->dateend = $this->context['view']->datemax;
}
$this->context['sql_date'] = ' AND sc.date BETWEEN
\''.$this->spectacles->escape($this->spectacles->getFormeDate($this->context['view']->datestart)).'\' AND
\''.$this->spectacles->escape($this->spectacles->getFormeDate($this->context['view']->dateend)).'\' ';
//mises-en-forme des dates au format de Francais
$this->context['view']->datestart = $this->spectacles->getFormeDate($this->context['view']->datestart,$GLOBALS['format_date']['fr']);
$this->context['view']->dateend = $this->spectacles->getFormeDate($this->context['view']->dateend,$GLOBALS['format_date']['fr']);
}
$this->spectacles->setZoneRecherche($this->context['where_zone'] ?? null);
// require_once PATH_ADMIN."app/common/helpers/aside/asidesUrlPagination.php";
$urlpagination = new asidesUrlPagination(
$this->context['view']->menu_structures[$this->context['action']]['url'],
array(
'd' => $this->context['view']->days,
'structure' => $this->context['idtypestructure'],
'area' => $area
),
$this->context
);
$this->context['view']->url_custom_pagination = $urlpagination->url_pagination();
}
// }}}
// {{{ region_common_asides()
/** Les asides communs aux spectacles
*
*/
public function region_common_asides(){
$this->context['view']->use_addthis = true;
$asides_top = new asides();
$asides_top->load(['aside_top' => array(
'php' => array(
'method' => 'asidesUrlRegions',
)
)
]);
$this->context['view']->aside_top = $asides_top->view($this->context['view']);
//pour afficher les asides correctements
//on supprime certains asides pour cette action
$asides_show_periode = true;
$is_region_videos = true; // Pour la couleur vidéos
if(in_array($this->context['action'],['region-videos'])){
$asides_show_periode = false;
$is_region_videos = false;
}
if(!$asides_show_periode){
unset($this->context['view']->menu_structures['region']);
unset($this->context['view']->menu_structures['region-coprod']);
}
else{
unset($this->context['view']->menu_structures['region-videos']);
unset($this->context['view']->menu_structures['textes-videos']);
}
// aside
$asides = new asides();
$asides->load(['url_lists' => array(
'exec' => ($is_region_videos) ? ['htmlstart' => true, 'color'=> 'spectacles'] : ['htmlstart' => true, 'color'=> 'videos'],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_structures,
'params' => array(
'activate' => $this->context['view']->action
),
'structure' => array(
'area' => $this->context['view']->area ?? null,
'structure_classic' => [
'd' => $this->context['view']->days,
'structure' => $this->context['idtypestructure'],
]
)
),
'title' => html_entity_decode('À l\'affiche')
)]);
$asides->load(['url_lists,spectacles_a_venir' => array(
//Nous fermons ou non l'aside, selon l'état de la variable $asides_show_periode
'exec' => ($asides_show_periode) ? ['alone' => false] : ['htmlend' => true],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['region']['days_array'],
'url' => '/spectacles/theatre/key_action/area/{v_area}',
'params' => array(
'key_action' => $this->context['view']->action,
'key_structure' => $this->context['idtypestructure'],
'activate' => $this->context['view']->days
),
'structure' => array(
'structure_classic' => array(
'idtypestructure' => 'key_structure',
'd' => 'key_day'
)
)
),
'title' => html_entity_decode('Recherche par période')
)
]);
//nous affichons les asides de période si l'état de la variable le permet ($asides_show_periode)
if($asides_show_periode){
$asides->load(['recherche_par_periode' => array(
'exec' => ['alone' => false],
'action' => $this->context['view']->url_custom_pagination
)
]);
$asides->load(['spectacles_choisir_ville' => array(
'exec' => ['alone' => false],
'url' => $this->context['view']->url_custom_pagination,
'title' => 'Recherche par ville'
)]);
$asides->load(['url_lists,tn_cdn_sn' => array(
'exec' => ['htmlend' => true],
'php' => [
'method' => 'tn_cdn_sn',
'url' => '/key_controller/generate_params',
'params' => array(
'activate' => (!is_null($this->context['idtypestructure'])) ? $this->context['idtypestructure'] : 'ALL',
'key_action' => $this->context['view']->action,
'key_area' => $this->context['view']->area
),
'structure' => array(
'theatre' => 'key_action',
'area' => 'key_area',
'structure_classic' => array(
'idtypestructure' => 'key_structure',
'd' => $this->context['view']->days
)
)
],
'title' => 'Rechercher par label'
)]);
}
if(in_array($this->context['action'],['region']))
{ $voir_videos = array(
array(
'name' => 'Spectacles avec vidéos',
)
);
$asides->load(['url_lists_alone,voir_videos'=> array(
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $voir_videos,
'url' => '/spectacles/theatre/region-videos/area/key_area',
'params' => array(
'key_area' => $this->context['view']->area
)
),
'title' => 'Voir aussi'
)]);
$asides->load(['common_carrer_informations'=> array(
'color' => 'spectacles'
)]);
}
//Chargement de la pub par région
asides::setEntityManager($this->em);
asides::loadaside('Publicite')->addWithRegion($asides, ['region' => $this->context['view']->area ?? null]); //$this->area
$asides->load(['common_carte' => array(
'exec' => ($is_region_videos) ? ['color'=> 'spectacles'] : ['color'=> 'videos'],
'url' => ($is_region_videos) ? "/spectacles/theatre/region/area/get_id" : "/spectacles/theatre/region-videos/area/get_id" ,
)]);
$this->context['view']->aside = $asides->view($this->context['view']);
//Tous les asides communs
// $this->region_common_asides();
}
// }}}
// {{{ action_region()
/** Spectacles à l'affiche dans les regions
*
* @Route("/spectacles/theatre/region/area/{p_area}", name="spectacles_region_area")
* @Route("/spectacles/theatre/region/area/{p_area}/liste", name="spectacles_region_area_liste")
*
*/
public function action_region($p_area = null)
{
$this->context['params']['area'] = $p_area;
$this->view->action = $this->context['action'] = 'region';
//Les données communes aux pages
$this->region_common();
$files = $this->em->getRepository(Files::class);
// formulaire de saisie
$city_list = $this->spectacles->getCityListSpectacle('prochains',180, $this->context['sql_area']);
ksort($city_list, SORT_LOCALE_STRING);
$this->context['formAsideSearch']->add('city', ChoiceType::class, [
'label' => 'A l\'affiche à',
'placeholder' => 'Choisissez une ville...',
'choices' => array_flip($city_list)
]);
$this->context['formAsideSearch']->add('datestart', TextType::class, [
'label' => 'Entre',
'attr' => [
'size'=>'10',
'id'=>'datestart'
]
]);
$this->context['formAsideSearch']->add('dateend', TextType::class, [
'label' => 'et',
'attr' => [
'size'=>'10',
'id'=>'dateend'
]
]);
$this->getCommonSearchView();
$limit_spectacles = 10;
$this->context['view']->region = true;
// spectacles dans la region
$params_sql_regions = array(
'params' => array(
'where' => $this->context['where_zone'].$this->context['sql_date'],
'limit' => 'all',
),
'special' => array(
'prochains' => true,
'publish_valid' => 1,
'prochains' => $this->context['view']->days
),
'dbg' => array('affiche_region','A l\'affiche en région')
);
if(!is_null($this->context['idtypestructure'])){
$params_sql_regions['special']['idtypestructure'] = $this->context['idtypestructure'];
$params_sql_regions['special']['structures_specifiques'] = $this->context['idtypestructure'];
}
$this->context['view']->nb_spectacles_total = $this->spectacles->countListSpectacles($params_sql_regions);
//La pagination
$urlpagination = new asidesUrlPagination(
$this->context['view']->menu_structures[$this->context['action']]['url'],
array(
'd' => $this->context['view']->days,
'structure' => $this->context['idtypestructure'],
'area' => $this->context['view']->area,
'datestart' => $this->context['view']->datestart,
'dateend' => $this->context['view']->dateend
),
$this->context
);
$this->perPage = $pagerOptions['perPage'] = 500; //On supprime la limite de résultats (10/03/2020 #79)
$pagination_url_custom = $urlpagination->url_pagination();
$this->context['view']->pagination = $this->getPagination($this->context['view']->nb_spectacles_total, 10, array('url_custom' => $pagination_url_custom));
$this->context['view']->pagination['totalItems'] = $this->context['view']->nb_spectacles_total;
$this->context['view']->pagination['spectacle'] = true;
$params_sql_regions['params']['limit'] = array($this->getLimitStart(),$this->perPage);
// supprimer la limite pour la recherche par date
if(!empty($sql_date)) {
$params_sql_regions['params']['limit'] = array(0,500);
unset($params_sql_regions['special']['prochains']);
// définir la date de début de recherche
$params_sql_regions['special']['depuis_le'] = $this->context['view']->datestart;
}
//on prépare la requête pour compter le nombre de répsentation
$params_query_count_schedules = $params_sql_regions;
unset($params_query_count_schedules['params']['limit']); //on supprime la imite pour récupérer le nombre total de représentations
$params_query_count = $this->spectacles->countListSchedules($params_query_count_schedules);
$this->context['view']->pagination['total_dates'] = number_format($params_query_count, 0, '', ' '); //on assigne le nombre total à la vue
$this->context['view']->pagination['representation_spectacle'] = true; //on force l'affichage des représentations
$spectacles_region = $this->spectacles->getListSpectacles($params_sql_regions,$this->context['region']['vignette'],false,array('allauthors' => true, 'carrer_couleurs' => true));
// suppléments
foreach($spectacles_region as $k=>$v) {
//ajout footer_contact pour region spectacles
$spectacles_region[$k]['footer_contact'] = true;
// titre du theatre en haut
$spectacles_region[$k]['bloc'] = true;
$spectacles_region[$k]['city_top'] = $spectacles_region[$k]['city'];
// voir si le contact du spectacle est un partenaire et récup son logo
$bandeau = $files->getAssociateFile($v['contact']['idcontact'], 'contacts','class_petit_bandeau');
if(!empty($bandeau)) {
//$spectacles_region[$k]['contact']['bandeau_partenaire'] = $bandeau['filepath']; // sans retaille
$spectacles_region[$k]['contact']['bandeau_partenaire'] = $_ENV['URL_DIRECTORYUPLOAD'].$files->getThumbnail($bandeau['file'],285,'thumb');
}
}
if (isset($city_list) && isset($this->context['view']->city)) {
$this->context['view']->city_name = $city_list[$this->context['view']->city];
}
$this->context['view']->spectacles_region = $spectacles_region;
//Tous les asides communs
$this->region_common_asides();
return $this->view('spectacles/region.html.twig');
}
// }}}
// {{{ action_region()
/** Spectacles à l'affiche dans les regions
*
*/
public function action_region_coprod()
{
//Les données communes aux pages
$this->region_common();
$regions = $this->em->getRepository(Bigregions::class);
$area = $this->context['view']->area;
$this->context['view']->no_city_list = true;
$this->context['view']->regioncoprod = true;
// spectacles en tournée coproduit par des contacts de la région
// Productteur (17), coprod (18), prod délégué (19). Recherche sur spectacle_contact+idrole
$where_idcontact = ' sct.idcontact IN (SELECT c.idcontact FROM contacts WHERE 1 '.$this->context['sql_area'].')';
$params_sql_coprod_regions = array(
'params' => array(
'from' => 'spectacle_contact sct',
'where' => ' AND sct.idspectacle=s.idspectacle AND sct.idrole IN (17,18,19) AND '.$where_idcontact,
'select' => 'contacts.idcontact as datecontact',
'limit' => 'all'
),
'special' => array(
'prochains' => true
),
);
if(!is_null($this->context['idtypestructure'])){
$params_sql_coprod_regions['special']['idtypestructure'] = $this->context['idtypestructure'];
}
$this->context['view']->nb_spectacles_total = $this->spectacles->countListSpectacles($params_sql_coprod_regions);
$this->context['view']->pagination = $this->getPagination($this->context['view']->nb_spectacles_total, 10);
$this->context['view']->pagination['totalItems'] = $this->context['view']->nb_spectacles_total;
// $params_sql_coprod_regions['params']['limit'] = array($paged_data['from']-1, $pagerOptions['perPage']);
$params_sql_coprod_regions['params']['limit'] = array($this->getLimitStart(),$this->perPage);
$spectacles_coprod_region = $this->spectacles->getListSpectacles($params_sql_coprod_regions,$this->context['region']['vignette'],true,array('allauthors' => true));
// parcourir pour trouver les coprod (17,18,19)
foreach($spectacles_coprod_region as $k=>$v) {
// trouver la prochaine date dans un lieu qui n'est pas dans la région ou dans le pays
if(!empty($other_country)) {
$sql_proch_city_date = '
SELECT DISTINCT(contacts.zip), contactsc.city
FROM schedules sc, contacts
WHERE sc.idcontact=contacts.idcontact AND contacts.country!=\''.$this->spectacles->escape($area).'\'
AND sc.idspectacle='.$k.'
AND sc.date>=\''.date('Y-m-d').'\' ORDER BY sc.date LIMIT 0,1';
} else {
$sql_proch_city_date = '
SELECT DISTINCT(contacts.zip), contacts.city
FROM schedules sc, contacts contacts
WHERE sc.idcontact=contacts.idcontact
'.$regions->getZipCode($area,'contacts','zip','NOT').'
AND sc.idspectacle='.$k.'
AND sc.date>=\''.date('Y-m-d').'\' ORDER BY sc.date LIMIT 0,1';
}
$proch_city_date = $this->spectacles->queryRow($sql_proch_city_date);
if(!PEAR::isError($proch_city_date) && !empty($proch_city_date)) {
// trouver les autres dates dans ce lieux hors de la région
$sql_proch_ext = 'SELECT MIN(sc.date) as datestart, MAX(sc.date) as dateend, c.city
FROM schedules sc, contacts
WHERE sc.idcontact=contacts.idcontact
AND sc.idspectacle='.$k.'
AND contacts.zip=\''.$proch_city_date['zip'].'\'
AND sc.date>=\''.date('Y-m-d').'\' ';
$prochedate_ext = $this->spectacles->queryAll($sql_proch_ext);
// les mettre au format français
$prochedate_ext[0]['datestart'] = $this->spectacles->getFormeDate($prochedate_ext[0]['datestart'],"%a %d/%m/%Y",true);
$prochedate_ext[0]['dateend'] = $this->spectacles->getFormeDate($prochedate_ext[0]['dateend'],"%a %d/%m/%Y",true);
// si datestart égal dateend, ne garder que dateend
if($prochedate_ext[0]['datestart']==$prochedate_ext[0]['dateend']) {
$prochedate_ext[0]['datestart'] = null;
}
} else {
$prochedate_ext = null;
}
// si prochdate_ext
if(!empty($prochedate_ext)) {
// si il n'y a que une date proche
if(empty($prochedate_ext[0]['datestart'])) {
$spectacles_coprod_region[$k]['prochdate'] = $prochedate_ext[0]['dateend'];
$spectacles_coprod_region[$k]['city'] = $prochedate_ext[0]['city'];
} else {
$spectacles_coprod_region[$k]['periode'] = $prochedate_ext[0];
$spectacles_coprod_region[$k]['prochdate'] = null;
}
$coproducteurs = null;
$sql_coprod = 'SELECT contacts.idcontact,contacts.organisation,contacts.url_clean FROM
contacts, spectacle_contact sct
WHERE
sct.idcontact=contacts.idcontact
'.$this->context['sql_area'].'
AND sct.idspectacle='.$k.'
AND sct.idrole IN (17,18,19) GROUP BY contacts.`idcontact`';
$coproducteurs = $this->spectacles->queryAll($sql_coprod,array(),null,false);
if(!PEAR::isError($coproducteurs) && !empty($coproducteurs)) {
$spectacles_coprod_region[$k]['coprod'] = noPunct($coproducteurs);
}
} else {
unset($spectacles_coprod_region[$k]);
}
}
$this->context['view']->spectacles_coprod_region = $spectacles_coprod_region;
//Tous les asides communs
$this->region_common_asides();
}
// }}}
// {{{ action_region_evenements()
/** Spectacles à l'affiche dans les regions
*
*/
public function action_region_evenements()
{
//Les données communes aux pages
$this->region_common();
$this->context['view']->regionevenements = true;
$area = $this->context['view']->area;
// récupérer les prochains évènements proposés en région qui sont validé et sont des évènements
$news = $this->em->getRepository(News::class);
$news_params = array(
'params' => array(
'limit' => array(0, 100),
),
'special' => array(
'prochains' => true,
'publish_valid' => true,
'type_news' => 'news',
),
'dbg' => array('prochains_news','Prochains évènements'),
);
if($news_params != "ALL"){
$params_sql_coprod_regions['special']['idtypestructure'] = $this->context['idtypestructure'];
}
if(my_is_int($area)) {
$news_params['special']['idbigregion'] = array($area);
} elseif($area=='BE' || $area=='CH') {
$news_params['special']['country'] = array($area);
}
$this->context['view']->news_list = $news->getListNews($news_params);
$news_params['special']['type_news'] = 'spectacles';
$this->context['view']->spectacles_list = $news->getListNews($news_params);
//Tous les asides communs
// $this->region_common_asides();
}
// }}}
// {{{ action_region_videos()
/** Spectacles à l'affiche dans les regions
*
* @Route("/spectacles/theatre/region-videos/", name="spectacles_region_videos")
* @Route("/spectacles/theatre/region-videos/area/{p_area}", name="spectacles_region_videos_area")
*
*/
public function action_region_videos($p_area = null)
{
$this->context['params']['area'] = $p_area;
$this->view->action = $this->context['action'] = 'region-videos';
//Les données communes aux pages
$route = $this->region_common();
if ($route != null) {
return $route;
}
$this->context['view']->regionvideos = true;
$sql_where_zone = "";
if (isset($this->context['where_zone'])) {
$sql_where_zone = 'AND '.$this->context['where_zone'];
}
// recherche de base
$params_query_affiches = array(
'where' => array(
//array('spectacles','idspectaclegenre',1), // uniquement les spectacles
$sql_where_zone, // condition géographique
),
'count' => true,
'affiche' => array('today' => $this->context['view']->days),
'limit' => array('all'),
'dbg' => array('affiche','Vidéos de spectacles à l\'affiche'),
);
//si l'utilisateur à sélectionné une région
if(!is_null($this->context['idtypestructure'])){
$params_query_affiches['special']['idtypestructure'] = $this->context['idtypestructure'];
}
$this->context['view']->nb_spectacles_total = $this->em->getRepository(Multimedias::class)->getListMultimedias($params_query_affiches);
$this->context['view']->nb_spectacles_total = count($this->context['view']->nb_spectacles_total);
// $this->context['view']->pagination = $paged_data = pagerSimple($pagerOptions);
$this->context['view']->pagination = $this->getPagination($this->context['view']->nb_spectacles_total, 10);
$this->context['view']->pagination['totalItems'] = $this->context['view']->nb_spectacles_total;
$this->context['view']->pagination['spectacle'] = true;
$params_query_affiches['limit'] = array($this->getLimitStart(),$this->perPage);
// $params_query_affiches['limit'] = array($paged_data['from']-1, $pagerOptions['perPage']);
$format_vignette = array('width'=>$_ENV['VIGN_VIDEO_WIDTH'],'height'=>$_ENV['VIGN_VIDEO_HEIGHT'],'fleche'=>'none','ratio' => '169');
$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));
// si vide, mettre plus de vidéos
if(empty($this->context['view']->videos)) {
$params_query_affiches['affiche'] = array('today' => 60);
$this->context['view']->videos = $this->em->getRepository(Multimedias::class)->getListMultimedias($params_query_affiches,$format_vignette,array('get_schedule' => true,'format_vignette' => true));
}
//Tous les asides communs
$this->region_common_asides();
return $this->view('spectacles/region-videos.html.twig');
}
// }}}
// {{{ action_region_soutien()
/** Spectacles à l'affiche dans les regions
*
*/
public function action_region_soutien()
{
//Les données communes aux pages
$this->region_common();
require_once PATH_LIBS.'Date/Date_time.php';
$this->context['view']->regionsoutien = true;
// saison courante
$saison = Date_time::getLastSaison(array(),true);
// spectacles soutenu par la region
$params_sql_soutien = array(
'params' => array(
//'where' => $where_genre.$where_zone.$sql_date,
'where' => $this->context['sql_date'],
'limit' => array(0,50),
),
'special' => array(
//'prochains' => true,
'publish_valid' => 1,
'aide' => array(
'idcontact' => 15995,
),
'spectacle_aide' => true,
'period' => array(
'start' => $saison['start'],
'end' => $saison['end'],
),
),
'dbg' => array('soutien','Spectacles avec le soutien de la région'),
);
$this->spectacles->setZoneRecherche(false);
$this->context['view']->saison = Date_time::getLastSaison();
$this->context['view']->spectacles_soutien = $this->spectacles->getListSpectacles($params_sql_soutien,$this->context['region']['vignette'],false);
//Tous les asides communs
$this->region_common_asides();
}
// }}}
// {{{ action_structures()
/** Spectacles à l'affiche dans des types de structures en particulier
*
* @Route("/spectacles/liste/structures", name="spectacles_liste_structures")
*
*/
public function action_structures()
{
$this->view->action = $this->context['action'] = 'structures';
// structures recherchées
$vignette_image = array();
$choix_type = array(
'SN',
'TN',
'CDN',
'SC'
);
// les types de structure
$typesstructure_list = $this->em->getRepository(Typesstructures::class)->getTypeStructureList(true,true,$choix_type);
// type de structure recherchée
if(!empty($_REQUEST['idtypestructure']) && array_key_exists($_REQUEST['idtypestructure'], $typesstructure_list)) {
$this->context['view']->idtypestructure = filter_var($_REQUEST['idtypestructure'], FILTER_SANITIZE_STRING);
} else {
$this->context['view']->idtypestructure = 'SN';
}
if(!empty($_REQUEST['directeur'])) {
$this->context['view']->requestDirecteur = filter_var($_REQUEST['directeur'], FILTER_SANITIZE_STRING);
}
// type courant pour la vue
foreach(array('typestructure','typestructure_pluriel') as $s) {
$typesstructure_list_simple[$s] = strtolower($typesstructure_list[$this->context['view']->idtypestructure][$s]);
}
$typesstructure_list_simple['idtypestructure'] = $this->context['view']->idtypestructure;
$this->context['view']->typestructure = $typesstructure_list_simple;
// contact pour ce type de structure
$contacts = $this->getContactsByType($this->context['view']->idtypestructure);
$this->context['view']->menu_content = array(
'spectacles' => array(
'name' => 'Tous les spectacles',
'name_view' => 'spectacles',
'key_type' => 'spectacles'
),
'spectacles-videos' => array(
'name' => 'Tous les spectacles avec vidéos',
'name_view' => 'spectacles avec vidéos',
'key_type' => 'spectacles-videos',
'activate' => 'spectacles/videos'
),
'coproductions' => array(
'name' => 'Coproductions à l\'affiche',
'name_view' => 'coproductions à l\'affiche',
'key_type' => 'coproductions'
),
'spectacles-directeurs' => array(
'name' => 'Tous les directeurs',
'name_view' => 'Tous les directeurs',
'key_directeur' => '1',
'activate' => 'spectacles/directeurs'
)
);
if(empty($_REQUEST['type']) || !array_key_exists($_REQUEST['type'], $this->context['view']->menu_content)) {
$this->context['view']->type = 'spectacles';
} else {
$this->context['view']->type = $_REQUEST['type'];
}
$this->context['view']->type_title = $this->context['view']->menu_content[$this->context['view']->type];
$this->context['view']->menu_jours = array(
3 => array('name' => '3 prochains jours'),
7 => array('name' => '7 prochains jours'),
30 => array('name' => '30 prochains jours'),
90 => array('name' => '3 prochains mois'),
365 => array('name' => '12 prochains mois'),
);
$nb_day_default = 365;
$vignette_image = array('vignette' => array(
'width'=>$_ENV['VIGN_SPECTACLE_WIDTH'],'height'=>$_ENV['VIGN_SPECTACLE_HEIGHT'],'direction'=>'crop','fleche'=>'moyen'
));
$this->getCommonSearch(array(
'saisons_annees' => $this->getSaisonsAndAnneesByContacts($contacts['ids']),
'nb_days' => $nb_day_default,
));
$this->getCommonSearchView();
$where_idcontact = ' AND contacts.idcontact IN ('.join(',', $contacts['ids']).') ';
// les spectacles à l'affiche avec des textes nonfictif
if($this->context['view']->type=='spectacles') {
$params_sql = $this->setCommonSearchSpectacles(array(
'params' => array(
'where' => $where_idcontact.' AND s.publish=1 ',
),
'special' => array(
'idcontact' => $contacts['ids'],
'prochains' => true
),
'dbg' => array('spectacles', 'Spectacles à l\'affiche pour ces contacts')
));
// directeur à l'affiche
if(!empty($this->context['view']->requestDirecteur) && $this->context['view']->requestDirecteur) {
// On récupère la liste des directeurs associé avec la structure recherché par l'utilisateur
$persons = $this->em->getRepository(Persons::class);
$sqlPersons = $persons->getSQLPersons(
[
'limit' => 'all',
],
[
'contact_person' => [
'idoffice' => 'directeur',
'idtypestructure' => $this->context['view']->idtypestructure,
'actual' => true,
],
]
);
$result = $persons->queryAll($sqlPersons, array(),null,true);
// mises-à-jours de nouveaux paramètres à la requête des spectacles
unset($params_sql['special']['idcontact']);
$params_sql['special']['join'] = true;
$params_sql['special']['textfictif'] = 0;
$params_sql['special']['join_person'] = [
'idperson' => !empty($result) ? array_keys($result) : null,
];
}
// Pour les autres cas de recherche (en dehors des directeurs)
// on recherche les spectacles joués dans les structures associés aux TN/SN/CDN
else {
$params_sql['params']['where'] .= $where_idcontact. '';
}
}
//les spectacles avec vidéos
else if($this->context['view']->type=='spectacles-videos') {
$getSpectaclesMultimedias = true;
$params_sql = array(
'where' => array(
array('spectacles','idspectaclegenre',1), // uniquement les spectacles
array('schedules','idcontact',$contacts['ids']), // uniquement dans ces structures
),
'affiche' => array('today' => $this->context['view']->days),
'limit' => 'all',
'dbg' => array('affiche','Vidéos de spectacles à l\'affiche'),
);
if(!empty($this->context['params']['area'])){
$where_zone = Theatre::factory('bigregions')->getZipCode(intval($this->context['params']['area']));
$params_sql['where'][] = str_replace('c.', 'contacts.', $where_zone); // condition géographiqu
}
//requête pour compter le nombre d'élément multimédias liés aux spectacles
$sql_counts_multimedias = $this->spectacles->getSQLSpectacles(
array(
'limit' => 'all',
'where' => 'AND s.idspectaclegenre = 1 AND sc.idcontact IN('.implode(',', $contacts['ids']).')',
),
array(
'prochains' => $this->context['view']->days,
'join' => true,
'count_only' => array(
'count_only_distinct' => 's.idSpectacle'
),
'contenus_associes_multimedias' => true,
)
);
$params_sql['limit' ] = array(0,10);
}
//spectacles avec coproduction à l'affiche
else {
$where_coprod = '
AND s.publish=1
AND sct.idspectacle=s.idspectacle
AND sct.idrole IN (17,18,19)
AND (
sct.idcontact IN ('.join(',', $contacts['ids']).')
OR s.idcontactProduction IN ('.join(',', $contacts['ids']).')
)';
// rechercher les coproductions
$params_sql = $this->setCommonSearchSpectacles(array(
'params' => array(
'from' => 'TheatreCore\Entity\SpectacleContact sct',
'where' => $where_coprod,
),
'special' => array(
'plus_proche' => true,
// 'idcontact' => $contacts['ids'],
),
'dbg' => array('spectacles_coprod', 'Spectacles à l\'affiche pour ces contacts')
));
}
// recherche par région
if(!empty($this->context['params']['area'])) {
$where_zone = Theatre::factory('bigregions')->getZipCode(intval($this->context['params']['area']));
$this->spectacles->setZoneRecherche($where_zone); // définir la zone de recherche
}
//si nous recherchons du contenu multimedias (spectacles avec vidéos)
if(isset($getSpectaclesMultimedias) && $getSpectaclesMultimedias){
$this->context['view']->spectacles_videos = true;
$this->context['view']->nb_spectacles_total = $sql_counts_multimedias->getOneOrNullResult();
//on lui indique la limite
$params_sql['limit'] = array($this->getLimitStart(),$this->perPage);
$this->context['view']->spectacles = $this->em->getRepository(Multimedias::class)->getListMultimedias($params_sql,array(),array('get_schedule' => $contacts['ids']));
//on assigne à la vue la pagination et ces valeurs
$this->context['view']->pagination = $this->getPagination($this->context['view']->nb_spectacles_total, 10);
}
//si nous rechercons des spectacles "classiques" (sans multimedias)
else{
/* pagiantion */
//nombre total de spectacles
$this->context['view']->nb_spectacles_total = $this->spectacles->countListSpectacles($params_sql);
//nombre total de représenations
$this->context['view']->nb_dates_total = $this->spectacles->countListSchedules($params_sql);
//on lui indique la limite
$params_sql['params']['limit'] = array($this->getLimitStart(),$this->perPage);
$this->context['view']->spectacles = $this->setBandeauPartenaire(
$this->spectacles->getListSpectacles(
$params_sql,
$vignette_image,
false,
array('allauthors' => true, 'carrer_couleurs' => true)
)
);
//on assigne à la vue la pagination et ces valeurs
$this->context['view']->pagination = $this->getPagination($this->context['view']->nb_spectacles_total, 10, array(
'total_dates' => $this->context['view']->nb_dates_total
));
$this->context['view']->pagination['spectacle'] = true;
// $this->context['view']->pagination['representation_spectacle'] = true;
}
$this->getAsidesStructures();
$this->title_page = $title_page = $this->context['view']->type_title['name'].' dans les '.$this->context['view']->typestructure['typestructure_pluriel'];
// situation et titre meta
$this->view->locate = array(
'/spectacles/' => 'Spectacles',
0 => $title_page,
);
return $this->view('spectacles/structures.html.twig');
}
// }}}
// {{{ action_theatre_recherche()
/** Recherche des spectacles dans les théâtres.
*
* @Route("/spectacles/theatre/recherche", name="spectacles_theatre_recherche")
*
* @return \Symfony\Component\HttpFoundation\Response
*
*/
public function action_theatre_recherche(Request $request)
{
$this->context['formAsideSearch'] = $this->get('form.factory')->createNamedBuilder('', FormType::class);
// formulaire de saisie recherche par titre
$this->context['formAsideSearch']->add('title', TextType::class, [
'label' => 'Mots du titre',
'attr' => [
'size' => '35',
'placeholder' =>'Rechercher un texte'
]
]);
$this->context['formAsideSearch']->add('search', SubmitType::class, [
'label' => 'OK',
'attr' => [
'class'=>'boutform'
]
]);
$this->getCommonSearchView($request);
$this->view->action = $this->context['action'] = 'recherche';
// instancier un objet spectacles
$spectacle = $this->em->getRepository(Spectacles::class);
// regions
$regions = $this->em->getRepository(Regions::class);
$form = $this->setCommonSearch();
// formulaire de saisie
// $form->add('director', TextType::class, [
// 'label' => 'Metteur en scène',
// 'attr' => [
// 'size' => '40'
// ]
// ]);
$form->add('idcontact_publisher', RelationsType::class, [
'label' => 'Éditeur',
'relat'=>'simple',
'type_dbdo' => 'contacts',
'required' => false
]);
$form->add('idperson_author', RelationsType::class, [
'label' => 'Auteur',
'relat'=>'simple',
'type_dbdo' => 'persons',
'required' => false
]);
$form->add('idperson_director', RelationsType::class, [
'label' => 'Metteur en scène',
'relat'=>'simple',
'type_dbdo' => 'persons',
'required' => false
]);
$form->add('area', ChoiceType::class, [
'label' => 'Region',
'choices' => array_flip($regions->getArea()),
'attr' => [
'class' => 'select_language'
],
'required' => false
]);
// nombre de resultat pas page
$nbpage_array = array('20'=>'20','40'=>'40','60'=>'60','80'=>'80');
$form->add('nbpagelimit', ChoiceType::class, [
'label' => 'Resultats par page',
'choices' => $nbpage_array,
'required' => false
]);
// crriteres de tri
$tri_array = array(
'author'=>'Auteur',
'titre'=>'Titre',
'date'=>'Date'
);
$form->add('tri', ChoiceType::class, [
'label' => 'Trier par',
'choices' => array_flip($tri_array),
'required' => false
]);
// region en GET
if(isset($_REQUEST['area'])) {
$area = $_REQUEST['area'];
// prochain 180 jours
if(isset($_GET['prochain'])) {
$prochain = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d')+180, date('Y')));
$this->view->prochain = 180;
}
}
$form = $form->getForm();
$form->handleRequest($request);
// si le formulaire est validé
if(($form->isSubmitted() && $form->isValid()) || isset($_GET['page']) || isset($area) || $this->context['formAsideSearch']->isSubmitted() || isset($_GET['start'])) {
// recuperation de variable
$title = $form->get('title')->getData();
if(empty($title) && isset($_GET['title'])) {
$title = $_GET['title'];
}
if(!empty($title)) {
$this->view->title = $title;
}
if($this->context['formAsideSearch']->isSubmitted() || isset($_GET['start'])) {
if ($this->context['formAsideSearch']->get('title')->getData() != null) {
$title = $this->context['formAsideSearch']->get('title')->getData();
} else if (empty($title) && isset($_GET['title'])) {
$title = $_GET['title'];
} else {
$title = "spectacle";
}
}
// $director = $form->get('director')->getData();
// if(empty($director) && isset($_GET['director'])) {
// $director = $_GET['director'];
// }
// if(!empty($director)) {
// $this->view->director = $director;
// }
$datestart = $form->get('datestart')->getData();
if(empty($datestart) && isset($_GET['datestart'])) {
$datestart = $_GET['datestart'];
}
if(!empty($datestart)) {
$this->view->datestart = $spectacle->getFormeDate($datestart,$GLOBALS['format_date']['fr']);
}
$dateend = $form->get('dateend')->getData();
if(empty($dateend) && isset($_GET['dateend'])) {
$dateend = $_GET['dateend'];
}
if(!empty($dateend)) {
$this->view->dateend = $spectacle->getFormeDate($dateend,$GLOBALS['format_date']['fr']);
}
if(!isset($area)) {
$area = $form->get('area')->getData();
}
if(empty($area) && isset($_GET['area'])) {
$area = $_GET['area'];
}
if(!empty($area)) {
$this->view->area = $regions->getRegionName($area);
}
$nbpagelimit = $form->get('nbpagelimit')->getData();
if(empty($nbpagelimit) && isset($_GET['nbpagelimit'])) {
$pagerOptions['perPage'] = $_GET['nbpagelimit'];
$nbpagelimit = $_GET['nbpagelimit'];
} else {
$pagerOptions['perPage'] = $nbpagelimit;
}
if(empty($nbpagelimit) || !array_key_exists($nbpagelimit,$nbpage_array)) {
$pagerOptions['perPage'] = 20;
}
// requete normale
$sql_normal = 'SELECT DISTINCT(s.idspectacle), s.idtypespectacle, s.url_clean, ty.typespectacle, s.creation_date, s.textfictif,
s.title as titlespectacle,
t.title as titletext, t.idtext, t.type as type, ty.typespectacle,
sc.date as prochdate, c.city';
// compter les resultats
$sql_count = 'SELECT COUNT(DISTINCT(s.idspectacle)';
$sql = null;
// dd($request, $sql, $sql_normal);
if(!empty($title)) {
$title = htmlspecialchars($title, ENT_COMPAT);
$title = trim($title);
$sql_normal .= ', MATCH(seat.title) AGAINST (\''.$spectacle->escape($title).'\') AS cpt, MATCH(seas.title) AGAINST (\''.$spectacle->escape($title).'\') as cpts';
$sql_count .= ', MATCH(seat.title) AGAINST (\''.$spectacle->escape($title).'\'), MATCH(seas.title) AGAINST (\''.$spectacle->escape($title).'\')';
}
// sql count suite
$sql_count .= ') as total ';
// from
$sql .= ' FROM spectacles s, typesspectacles ty, texts t, text_spectacle ts, schedules sc,
contacts c, persons pd, spectacle_person sp, searchs_texts seat, searchs_spectacles seas';
// conditions
//ddAND t.idtext=ta.idtext
$sql .= ' WHERE t.idtext=ts.idtext
AND s.idspectacle=ts.idspectacle
AND s.idspectacle=sc.idspectacle
AND s.idtypespectacle=ty.idtypespectacle
AND sc.idcontact=c.idcontact
AND (sp.idperson=pd.idperson AND s.idspectacle=sp.idspectacle)
AND t.idtext=seat.idtext
AND s.idspectacle=seas.idspectacle
AND s.publish=\'1\' AND (t.publish=\'1\' || t.textfictif=\'1\')';
if (!empty($title)) {
// on match directement
$sql .= ' AND ( MATCH(seat.title) AGAINST (\''.$spectacle->escape($title).'\' IN BOOLEAN MODE)
OR MATCH(seas.title) AGAINST (\''.$spectacle->escape($title).'\' IN BOOLEAN MODE)
)';
}
// recherche par metteur en scene
if (!empty($director)) {
$director = htmlspecialchars($director, ENT_COMPAT);
$director = addslashes($director);
// decouper la chaine
$directorarray = explode(' ', trim($director));
if (count($directorarray) > 0) {
$kwtemparray = array();
foreach($directorarray as $ck) {
$kwtemparray[] = " pd.lastname LIKE '%$ck%' ";
}
$sql .= 'AND (' . implode(' OR ', $kwtemparray) . ') ';
}
}
// recherche avec la date
if(!empty($datestart)) {
$tabdatestart = explode('/', $datestart);
$start_year = (int)$tabdatestart[2];
$start_month = (int)$tabdatestart[1];
$start_day = (int)$tabdatestart[0];
if (checkdate((int)$start_month, (int)$start_day, (int)$start_year)) $datestart = $start_year . '-' . $start_month . '-' . $start_day;
}
if(!empty($dateend)) {
$tabdateend = explode('/', $dateend);
$end_year = (int)$tabdateend[2];
$end_month = (int)$tabdateend[1];
$end_day = (int)$tabdateend[0];
if (checkdate((int)$end_month, (int)$end_day, (int)$end_year)) $dateend = $end_year . '-' . $end_month . '-' . $end_day;
}
// recherche par date
if (!empty($datestart) && !empty($dateend)) {
$sql .= ' AND (sc.date BETWEEN (\'' . $datestart . '\') AND (\'' . $dateend . '\'))';
}
// si prochain
if(isset($prochain)) {
$sql .= ' AND (sc.date BETWEEN (\''.date('Y-m-d').'\') AND (\''.$prochain.'\'))';
}
// $month = $form->get('month')->getData();
if(empty($month) && isset($_GET['month'])) {
$month = $_GET['month'];
}
if(!empty($month)) {
// date (mois + annee)
$tab = explode('-',$month);
$month = $tab[0];
$year = $tab[1];
$datestart = date('Y-m-d',mktime(0,0,0,$month,1,$year)); //premier du mois
$dateend = date('Y-m-d',mktime(0,0,0,$month+1,0,$year)); //dernier du mois
$this->view->dateend = $spectacle->getFormeDate($dateend,$GLOBALS['format_date'][$lng]);
$this->view->datestart = $spectacle->getFormeDate($datestart,$GLOBALS['format_date'][$lng]);
//requete
$sql .= ' AND (sc.date BETWEEN (\''.$datestart.'\') AND (\''.$dateend.'\'))';
}
// recherche par region
if (!empty($area)) {
//nom de la region
$lgarea = $regions->getRegionName($area);
//liste des departements de la region
$listedept = $regions->getZipCode($area, "c");
//region
$sql .= ' AND ' . $listedept;
}
//echo $sql_normal.$sql.$limit;//
// nombre d'enregistrement
$totalItems = $spectacle->queryOne($sql_count.$sql);
if(!empty($totalItems) && $totalItems>0) {
$pagerOptions['totalItems'] = $totalItems;
// pagination
// require PATH_LIBS.'Pager/Pagersimple.php';
//$this->view->pagination = $paged_data = pagerSimple($pagerOptions);
$urlpagination = new asidesUrlPagination(
'/spectacles/theatre/recherche/generate_params',
array(
//'day' => $context['view']->days,
'title' => $title,
'area' => $area,
'nbpagelimit' => $nbpagelimit,
'datestart' => $datestart,
'dateend' => $dateend
),
$this->context
);
// $view->pagination = $paged_data = pagerSimple($pagerOptions);
$this->view->pagination['spectacle'] = true;
$this->view->pagination['url_custom'] = $urlpagination->url_pagination();
// ajout des criteres de tri apres avoir fait le count
$sql .= ' GROUP BY s.idspectacle ';
//$sql .= " ORDER BY cpts,cpt,s.creation_date DESC";
if(!empty($title)) {
$sql .= ' ORDER BY cpts,cpt DESC';
} elseif(isset($prochain)) {
$sql .= ' ORDER BY sc.date ASC';
} else {
$sql .= ' ORDER BY sc.date DESC';
}
//limite
$limit = ' LIMIT '.$this->getLimitStart().', '.$this->perPage;
// $limit = array($this->getLimitStart(),$this->perPage);
// executer la requete
$datas = $spectacle->query($sql_normal.$sql.$limit);
$spec = [];
// mettre en forme chaque reponse
foreach($datas AS $data)
{
$spectacle->loadResult($data);
// infos
$idspectacle = $spectacle->idspectacle;
$spec[$idspectacle] = $spectacle->getInfosSpectacleRow();
// trouver la prochaine et/ou la derniere date
//$spec[$idspectacle]['prochdate'] = $spectacle->getFormeDate($spectacle->prochdate,'%a %d/%m/%Y',true);
//$spec[$idspectacle]['city'] = $spectacle->city;
$spec[$idspectacle]['title_cut'] = $spectacle->cutSentence($spec[$idspectacle]['title'], 50);
// vignette
$spec[$idspectacle]['vignette_affiche'] = $spectacle->getVignetteSpectacle($idspectacle);
//carrer de couleurs
$spec[$idspectacle]['carrer'] = $spectacle->getObjectsCarrerDetails($idspectacle);
}
//passer le spectacle au template
$this->view->spec = $spec;
// liens du pager
// $paged_data['links'] = str_replace('spectacles/recherche/index.php', '', $paged_data['links']);
//setDebug($paged_data);
// if($paged_data['to']<$paged_data['totalItems']) {
// $paged_data['page_numbers']['next_page'] = $paged_data['page_numbers']['current']+1;
// }
}
}
// situation et titre meta
$this->view->locate = [
'/spectacles/' => 'Spectacles',
0 => 'Rechercher des spectacles'
];
$this->title_page = 'Recherche de spectacles de theatre';
$this->rub_courante = 'spectacles';
// jquery
$this->view->jquery_cal = 'datepicker';
$this->view->jquery_flash = true;
return $this->view('spectacles/recherche.html.twig', [
'form' => $form->createView()
]);
}
/**
* @Route("/spectacles/theatre/affiche-videos", name="spectacles_affiche_videos")
*
* @return \Symfony\Component\HttpFoundation\Response
*
*/
public function action_affiche_video()
{
$this->view->action = $this->context['action'] = 'affiche-videos';
$multimedias = $this->em->getRepository(Multimedias::class);
$spectacles = $this->em->getRepository(Spectacles::class);
//menu pour l'aside Spéctacles à venir
$spectacles_a_venir = array(
array(
'name' => 'Dans les 7 prochains jours',
'key_day' => '7',
),
array(
'name' => 'Dans les 30 prochains jours',
'key_day' => '30',
),
array(
'name' => 'Dans les 3 prochains mois',
'key_day' => '90',
),
array(
'name' => 'Dans les 12 prochains mois',
'key_day' => '365',
),
);
$day_spectacles = 365; $day_all = false;
if(!empty($_REQUEST['d'])){
if(in_array($_REQUEST['d'], array_column($spectacles_a_venir, 'key_day'))){
$day_spectacles = intval($_REQUEST['d']);
if(!is_numeric($day_spectacles)){
$day_all = true;
}
}
}
$this->context['view']->jours_affiche = $day_spectacles;
$this->context['view']->jours_affiche_all = $day_all;
// recherche de base
$params_query_count = array(
'prochains' => $day_spectacles
);
$params_query_affiches = array(
'affiche' => array('today' => $day_spectacles),
'limit' => array(0,100),
'dbg' => array('affiche','Vidéos de spectacles à l\'affiche'),
);
$this->context['view']->insert_block = 'spectacles/affiche-videos.choix.inc.html';
// dates de debut et de fin
$this->getCommonSearch();
$this->getCommonSearchView();
// trouver le spectacle avec la date la plus éloignée ou les dates
$sql = 'SELECT MAX(sc.`date`)
FROM schedules sc
JOIN object_multimedia om ON om.`idobject`=sc.`idspectacle`
WHERE
om.`object`=\'spectacles\'
AND sc.`date`>=\''.date('Y-m-d').'\'';
$datemax = $multimedias->queryOne($sql);
$this->context['view']->datemax = $datemax;
// datestart ?
if(isset($_REQUEST['datestart']) && !empty($_REQUEST['datestart'])) {
$datestart = filter_var($_REQUEST['datestart']);
} else {
$datestart = null;
}
// dateend ?
if(isset($_REQUEST['dateend']) && !empty($_REQUEST['dateend'])) {
$dateend = filter_var($_REQUEST['dateend']);
} else {
$dateend = null;
}
// si datestart et dateend, on recherche dans la période
if(!empty($datestart) && !empty($dateend)) {
// paser a la vue
$this->context['view']->datestart = $datestart;
$this->context['view']->dateend = $dateend;
// convertir en en
$datestart = $multimedias->getFormeDate($datestart);
$dateend = $multimedias->getFormeDate($dateend);
// les dates doivent être entre hier et le max
if($datestart<date('Y-m-d')) {
$datestart = date('Y-m-d');
}
if($dateend>$datemax) {
$dateend = $datemax;
}
$params_query_affiches['affiche'] = array(
'datestart' => $datestart,
'dateend' => $dateend
);
$params_query_count = array(
'prochains' => array($datestart, $dateend)
);
}
$params_query_count_schedules = array(
'special' => array(
'prochains' => $params_query_count['prochains']
)
);
$count_videos = $spectacles->countSpectaclesWithMultimedias($params_query_count);
$totalRepresentations = $spectacles->countListSchedules($params_query_count_schedules);
if($count_videos > 0){
$this->perPage = 20;
// pagination
$this->context['view']->pagination = $this->getPagination($count_videos);
$this->view->pagination['spectacle'] = true;
$this->view->pagination['representation_spectacle'] = true;
$this->view->pagination['total_dates'] = number_format($totalRepresentations, 0, '', ' ');
$this->view->pagination['url_custom'] = '/spectacles/theatre/affiche-videos/?d='.intval($day_spectacles);
// TODO à revoir ici aussi
$paged_data['from'] = 10;
$params_query_affiches['limit'] = array($this->getLimitStart(), $this->perPage);
}
$format_vignette = array('width'=>$_ENV['VIGN_VIDEO_WIDTH'],'height'=>$_ENV['VIGN_VIDEO_HEIGHT'],'fleche'=>'none','ratio' => '169');
$this->context['view']->videos = $multimedias->getListMultimedias($params_query_affiches,$format_vignette,array('get_schedule' => true,'format_vignette' => true));
// situation et titre meta
$this->view->locate = array(
'/spectacles/' => 'Spectacles',
0 => 'À l\'affiche en vidéo'
);
$this->title_page = 'Vidéos de spectacles à l\'affiche';
$this->rub_courante = 'spectacles';
// jquery
$this->context['view']->jquery_cal = 'datepicker';
//Menu
$spectacles_voir = array(
array(
'name' => 'Tous les spectacles',
'key_filtre' => '', // TODO: fixe v2
'action' => 'view',
),
array(
'name' => 'Tous les spectacles avec vidéos',
'key_filtre' => 'theatre/affiche-videos/',
'action' => 'affiche-videos',
)
);
$filtre_spectacles = 'view';
if(in_array($this->context['action'], array_column($spectacles_voir, 'action'))){
$filtre_spectacles = $this->context['action'];
}
// aside top
$asides_top = new asides();
$asides_top->load(['aside_top' => array(
'php' => array(
'method' => 'asidesUrlListMenuVideos',
)
)
]);
$this->context['view']->aside_top = $asides_top->view($this->context['view']);
//aside
$asides = new asides();
$asides->load(['url_lists,spectacles_voir' => array(
'exec' => array(
'htmlstart' => true,
'color' => 'videos'
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $spectacles_voir,
'url' => '/spectacles/key_filtre',
'params' => array(
'activate' => $filtre_spectacles
)
),
'title' => html_entity_decode('À l\'affiche'),
)]);
$asides->load(['url_lists,jours_a_venir' => array(
'exec' => array(
'alone' => false,
'color' => 'videos'
),
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $spectacles_a_venir,
'url' => '/spectacles/theatre/affiche-videos/?d=key_day',
'params' => array(
'activate' => $day_spectacles
)
),
'title' => html_entity_decode('Recherche par période'),
)]);
$asides->load(['recherche_par_periode' => array(
'exec' => array(
'htmlend' => true,
'color' => 'videos'
),
'url' => '/spectacles/theatre/affiche-videos/'
)]);
$asides->load(['url_lists_alone,tn_cdn_sn' => array(
'exec' => ['color' => 'videos'],
'php' => [
'url' => '/spectacles/liste/structures',
'method' => 'tn_cdn_sn',
'params' => array(
'activate' => (isset($this->context['view']->typestructure['idtypestructure'])) ? $this->context['view']->typestructure['idtypestructure'] : 'ALL'
),
'structure' => array(
'structure_classic' => array(
'idtypestructure' => 'key_structure'
)
)
],
'title' => 'Voir dans'
)]);
$asides->load(['common_carte' => array(
'exec' => ['color' => 'videos'],
'url' => '/spectacles/theatre/region-videos/area/get_id?d=365'
)]);
$menu = array(
array(
'name' => 'Mes videos favorites',
'key_sub' => 'videos',
),
array(
'name' => 'Mes videos modifiables',
'key_sub' => 'mesvideos',
),
);
$asides->load(['url_lists_alone' => array(
'exec' => ['color' => 'index'],
'php' => [
'method' => 'asidesUrlLists',
'urls' => $menu,
'url' => '/montheatre/key_sub'
],
'title' => 'Mon théâtre'
)]);
asides::setEntityManager($this->em);
asides::loadaside('Publicite')->addWithNational($asides); //$this->area
$asides->load(['common_participer' => array(
'exec' => ['color' => 'videos'],
'php' => array(
'method' => 'asidesUrlLists_Ajoutez'
)
)]);
$this->context['view']->aside = $asides->view($this->context['view']);
//On affiche la publicité google
$asides_publicite = new asides();
asides::setEntityManager($this->em);
asides::loadaside('Publicite')->addGoogle($asides_publicite, $this->serviceAbonnements);
$this->context['view']->asides_publicite = $asides_publicite->view($this->context['view']);
return $this->view('spectacles/affiche-videos.html.twig');
}
// {{{
public function getAsidesStructures()
{
$this->title_page = $this->context['view']->type_title['name'].' dans les '.$this->context['view']->typestructure['typestructure_pluriel'];
// situation et titre meta
$this->view->locate = array(
'/spectacles/' => 'Spectacles',
0 => $this->title_page,
);
// ajouter masonery
$this->context['view']->js_more[] = 'jquery.masonry.min.js';
foreach($this->context['view']->spectacles as $k=>$v) {
$this->context['view']->spectacles[$k]['footer_contact'] = true;
}
// jajascript
$this->context['view']->js_more[] = 'jquery.masonry.min.js';
$this->context['view']->jquery_cal = 'datepicker';
$this->context['view']->use_addthis = true;
$asides_top = new asides();
$asides_top->load(['aside_top' => array(
'php' => array(
'method' => 'asidesUrlListsMenuCDN',
'activate' => (!empty($this->context['view']->menu_content[$this->context['view']->type]['activate'])) ? $this->context['view']->menu_content[$this->context['view']->type]['activate'] : ''
)
)
]);
$spectacles_videos = false;
if($this->context['view']->type=='spectacles-videos') {
unset($this->context['view']->menu_content['spectacles']);
unset($this->context['view']->menu_content['coproductions']);
$spectacles_videos = true;
}
else{
unset($this->context['view']->menu_content['spectacles-videos']);
}
//on execute les asides pour le menu top
$this->context['view']->aside_top = $asides_top->view($this->context['view']);
// On ajoute des placeholder au input
// $form->addElement('text', 'datestart', 'Entre', array('size'=>'10','id'=>'datestart','placeholder' => 'Début'));
// $form->addElement('text', 'dateend', 'et', array('size'=>'10','id'=>'dateend','placeholder' => 'Fin'));
$asides = new asides();
$asides->load(['url_lists,navigation_spectacles' => array(
'exec' => ($spectacles_videos) ? ['htmlstart' => true, 'color'=> 'videos'] : ['htmlstart' => true, 'color'=> 'spectacles'],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_content,
'url' => '/spectacles/liste/structuresgenerate_params',
'params' => array(
'activate' =>
!empty($this->__getView('requestDirecteur'))
? $this->__getView('requestDirecteur')
: $this->__getView('type')
),
'structure' => array(
'structure_classic' => array(
'd' => 'v_days',
'type' => 'key_type',
's' => 'v_saison',
'y' => 'v_year',
'dateend' => 'v_dateend',
'datestart' => 'v_datestart',
'idtypestructure' => 'v_idtypestructure',
'directeur' => 'key_directeur',
)
)
),
'title' => html_entity_decode('À l\'affiche'),
)]);
$asides->load(['url_lists,spectacles_a_venir' => array(
'exec' => ($spectacles_videos) ? ['alone' => false, 'color'=> 'videos'] : ['alone' => false, 'color'=> 'spectacles'],
'php' => array(
'method' => 'asidesUrlLists',
'urls' => $this->context['view']->menu_jours,
'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}',
'params' => array(
'key_day' => 'auto_key'
),
'structure' => array(
'structure_classic' => array(
'd' => 'key_day',
'type' => 'v_type',
'y' => 'v_year',
'idtypestructure' => 'v_idtypestructure'
)
)
),
'title' => html_entity_decode('Recherche par période'),
)]);
if(!$spectacles_videos){
$asides->load(['recherche_par_periode' => array(
'exec' => ($spectacles_videos) ? ['alone' => false, 'color'=> 'videos'] : ['alone' => false, 'color'=> 'spectacles'],
'php' => array(
'method' => 'asidesUrlListsForms',
'url' => '/spectacles/liste/structuresgenerate_params',
'params' => array(
'k_type' => $this->view->type,
'k_typestructure' => $this->view->idtypestructure
),
'structure' => array(
'structure_classic' => array(
'type' => 'k_type',
'idtypestructure' => 'k_typestructure'
)
)
)
)]);
}
$asides->load(['par_saison_alone' => array(
'exec' => array(
'htmlend' => true
)
)]);
$asides->load(['url_lists_alone,tn_cdn_sn' => array(
'exec' => ($spectacles_videos) ? ['color'=> 'videos'] : ['color'=> 'spectacles'],
'php' => [
'method' => 'tn_cdn_sn',
'url' => '/key_controller/liste/structures/generate_params',
'params' => array(
'activate' => $this->context['view']->typestructure['idtypestructure'],
'url_custom' => ['ALL' => '/spectacles/']
),
'structure' => array(
'structure_classic' => array(
'd' => 'v_days',
'type' => 'v_type',
's' => 'v_saison',
'y' => 'v_year',
'dateend' => 'v_dateend',
'datestart' => 'v_datestart',
'idtypestructure' => 'key_structure'
)
)
],
'title' => 'Voir dans'
)]);
if(!$spectacles_videos){
$asides->load(['common_carrer_informations'=> array(
'color' => 'spectacles'
)]);
}
$asides->load(['common_carte' => array(
'exec' => ($spectacles_videos) ? ['color'=> 'videos'] : ['color'=> 'spectacles'],
'php' => [
'method' => 'asidesUrlLists',
'url' => ($spectacles_videos) ? '/spectacles/theatre/region-videos/area/get_id/' : '/key_controller/theatre/region/area/get_id/liste?idtypestructure={v_idtypestructure}',
'params' => array(
'key_controller' => $this->context['controller']
)
]
)]);
$asides->load(['spectacles_infos' => array(
'exec' => ($spectacles_videos) ? ['color'=> 'videos'] : ['color'=> 'spectacles']
)]);
$this->context['view']->aside = $asides->view($this->context['view']);
}
// }}}
// {{{ action_xml_structures()
/** Cartes de France
*
*/
public function action_xml_structures() { $this->getCommonXmlCarte(); }
// }}}
// {{{ getContactsByType()
/** Les contacts par tupe de structure avec bandeau
*
*/
public function getContactsByType($idtypestructure) {
// rechercher les scènes conventionnées
$params_sql_typestructure = array(
'where' => array(
array('contacts', 'idtypestructure', $idtypestructure),
array('contacts', 'country', 'FR'),
' AND contacts.idcontact NOT IN (SELECT idcontact FROM contact_classification WHERE idclassification=99) ',
),
'order' => array('contacts' => 'organisation'),
'direction' => 'ASC',
'idclassification' => array('NOT' => array(99)),
'limit' => array(0,500),
'dbg' => array('structures','Contacts avec un type précis'),
);
$structures = $this->em->getRepository(Contacts::class)->getListContacts($params_sql_typestructure);
// classe fichiers
$files = $this->em->getRepository(Files::class);
foreach($structures as $k=>$s) {
$ids_contact[] = $s['idcontact'];
// voir si la structure à une petite bannière
$structures[$k]['petit_bandeau'] = $files->getObjectFiles($s['idcontact'],'contacts',114);
}
return array(
'contacts' => $structures,
'nb_contacts' => count($structures),
'ids' => $ids_contact,
);
}
// }}}
// {{{
/**
*
* @Route("/spectacles/statut/non-accessible", name="spectacles_non_accessible")
*
* @return bool|\Symfony\Component\HttpFoundation\Response
*
*/
public function action_non_accessible()
{
return $this->view('spectacles/non-accessible.html.twig');
}
// }}}
// {{{ getSaisonsAndAnneesByContacts()
/** Les saisons/années de spectacle pour des contacts
*
*/
public function getSaisonsAndAnneesByContacts($ids_contact) {
$saisons = array();
$saisons_key = array();
$annees = array();
// grouper les dates par saisons => dans les lieux
$sql_annees = 'SELECT schedules.`date`, YEAR(schedules.`date`) as annee
FROM schedules, spectacles
WHERE schedules.`idspectacle`=spectacles.`idspectacle`
AND spectacles.`publish`=1
AND schedules.`idcontact` IN ('.join(',', $ids_contact).')
AND schedules.`date` > \'1999-12-31\'
ORDER BY schedules.`date` ';
$listdates = $this->spectacles->queryAll($sql_annees);
// debug de la boucle
if(!empty($_REQUEST['dbg_sql_object'])) {
$this->spectacles->setTraceInfos(array(
'execution_time_boucle' => (microtime(true) - $start_sql),
'nb_occurence' => count($listdates),
'sql_query' => $sql_annees,
'dbg' => array('dates', 'Liste des dates'),
));
}
// liste des saisons et des années
if(empty($listdates)) {
return $listdates->getDebugInfos();
} elseif(!empty($listdates)) {
foreach($listdates as $a) {
if($a['date']>date('Y-m-d', mktime(0,0,0,8,31,$a['annee'])) ) {
$s = $a['annee'].'-'.($a['annee']+1);
} else {
$s = ($a['annee']-1).'-'.$a['annee'];
}
$saisons[$s] = $s;
$saisons_key[] = $s;
$annees[$a['annee']] = $a['annee'];
}
}
return array(
'saisons' => $saisons,
'saisons_key' => $saisons_key,
'annees' => $annees,
);
}
// }}}
// {{{ setBandeauPartenaire()
/** Ajout du bandeau partenaire pour des blocs spectacles
*
*/
public function setBandeauPartenaire($spectacles) {
// bandeau partenaire
if(!empty($spectacles)) {
$files = $this->em->getRepository(Files::class);
foreach($spectacles as $k=>$v) {
$spectacles[$k]['bloc'] = true;
if(!empty($spectacles[$k]['city'])) {
$spectacles[$k]['city_barre'] = $spectacles[$k]['city'];
}
if(!empty($v['contact']['idcontact'])) {
$bandeau_partenaire = $files->getObjectFiles($v['contact']['idcontact'],'contacts',114);
if(!empty($bandeau_partenaire)) {
$spectacles[$k]['contact']['bandeau_partenaire'] = $bandeau_partenaire[0]['url_file_path'];
}
}
}
}
return $spectacles;
}
// }}}
// {{{ setCommonSearch()
/** Fonction pour le block de recherche commun
*
*/
public function setCommonSearch()
{
$form = $this->get('form.factory')->createBuilder(FormType::class, null, [
'attr' => [
'id' => 'masterform'
]
]);
$form->add('title', TextType::class, [
'label' => 'Titre de la pièce',
'attr' => [
'size' => '35'
],
'required' => false
]);
$form->add( 'validation', SubmitType::class, [
'label' => 'Lancer la recherche',
'attr' => [
'class'=>'boutform'
]
]);
$form->add('datestart', TextType::class, [
'label' => 'Entre',
'attr' => [
'size'=>'7',
'id'=>'datestart',
'placeholder' => 'Début'
],
'required' => false
]);
$form->add( 'dateend', TextType::class, [
'label' => 'et',
'attr' => [
'size'=>'7',
'id'=>'dateend',
'placeholder' => 'Fin'
],
'translation_domain' => false,
'required' => false
]);
// $month_list = month();
// $form->add('month', $this->context['tr']->trans('mois'), ChoiceType::class, [
// 'choices '=> $month_list,
// 'attr' => [
// 'class'=>'select_type'
// ]
// ]);
return $form;
}
// }}}
}