src/Controller/ContactsController.php line 508

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\Typesstructures;
  21. class ContactsController extends TheatreController
  22. {
  23.     // {{{ _construct()
  24.     /** constructeur hérité
  25.      *
  26.      */
  27.     public function __construct(EntityManagerInterface $emTranslatorInterface $translatorTokenStorageInterface $tokenStorageAbonnements $abonnements)
  28.     {
  29.         // load new aside
  30.         $this->asides = new asides();
  31.         $GLOBALS['rub_courante'] = 'contacts';
  32.         $this->em $em;
  33.         $this->serviceAbonnements $abonnements;
  34.         // hérite du constructeur parent
  35.         parent::__construct($translator$tokenStorage);
  36.     }
  37.     /**
  38.      * @Route("/contacts/", name="contacts_view")
  39.      */
  40.     public function action_view(Functions $functionsRequest $request)
  41.     {
  42.         $this->view->action $this->context['action'] = 'view';
  43.         $contacts $this->em->getRepository(Contacts::class);
  44.         $regions $this->em->getRepository(Bigregions::class);
  45.         // type de structure
  46.         $typesstructures $this->em->getRepository(Typesstructures::class);
  47.         $selected_types = array('TN','CDN','SN','SC');
  48.         // alphabet
  49.         $alphabet_simple $functions->getAlphaUpper();
  50.         // recherche par lettre soit on a le parametre,
  51.         // soit une lettre au hasard
  52.         if (isset($_GET['lettre']) && strlen($_GET['lettre']) == 1) {
  53.             $alpha strtoupper($_GET['lettre']);
  54.         } else {
  55.             $alpha null;
  56.         }
  57.         foreach($alphabet_simple as $lettre=>$upperlettre) {
  58.             $alphabet[$lettre]['nom'] = $upperlettre;
  59.             if ($upperlettre==$alpha) {
  60.                 $alphabet[$lettre]['active'] = 'active';
  61.             }
  62.         }
  63.         $this->view->alphabet $alphabet;
  64.         $typesstructure_list $typesstructures->getTypeStructureList(true,true);
  65.         // liste simple
  66.         foreach($selected_types as $s) {
  67.             $liste_selected_types[$s] = $typesstructure_list[$s];
  68.         }
  69.         //setDebug(print_r($liste_selected_types,true));
  70.         $this->view->liste_selected_types $liste_selected_types;
  71.         $this->context['formAsideSearch'] = $this->get('form.factory')->createNamedBuilder(''FormType::class);
  72.         // choix du type
  73.         foreach($typesstructure_list as $k=>$v) {
  74.             $typesstructure_list_select[$k] = $v['typestructure_pluriel'];
  75.         }
  76.         $this->context['formAsideSearch']->add('idtypestructure'ChoiceType::class, [
  77.             'label' => 'Type de structure',
  78.             'placeholder' => 'Choisissez dans la liste...',
  79.             'choices' => array_flip($typesstructure_list_select),
  80.             'required' => false,
  81.             'attr' => [
  82.                 'id' => 'idtypestructure'
  83.             ]
  84.         ]);
  85.         // formulaire de saisie recherche contact
  86.         $this->context['formAsideSearch']->add('organisation'TextType::class, [
  87.             'label' => 'Nom de la structure',
  88.             'required' => false,
  89.             'attr' => [
  90.                 'size' => '35'
  91.             ]
  92.         ]);
  93.         $this->context['formAsideSearch']->add('city'TextType::class, [
  94.             'label' => 'Ville',
  95.             'required' => false,
  96.             'attr' => [
  97.                 'size' => '35'
  98.             ]
  99.         ]);
  100.         $this->context['formAsideSearch']->add('zip'TextType::class, [
  101.             'label' => 'Code postal',
  102.             'required' => false,
  103.             'attr' => [
  104.                 'size' => '15'
  105.             ]
  106.         ]);
  107.         $this->context['formAsideSearch']->add('area'ChoiceType::class, [
  108.             'label' => 'R&eacute;gion',
  109.             'required' => false,
  110.             'choices' => $regions->getArea(),
  111.             'attr' => [
  112.                 'class' => 'select_language',
  113.                 'id' => 'area'
  114.             ]
  115.         ]);
  116.         $this->context['formAsideSearch']->add('search_contact'SubmitType::class, [
  117.             'label' => 'Lancer la recherche',
  118.             'attr' => [
  119.                 'class'=>'boutform'
  120.             ]
  121.         ]);
  122.         $this->getCommonSearchView($request);
  123.         // les requetes classiques
  124.         $query_normal 'SELECT DISTINCT(c.`idcontact`), c.`organisation`, c.`country`, c.`city`, c.`url_clean` FROM contacts c';
  125.         // compte
  126.         $query_count 'SELECT COUNT(DISTINCT(c.`idcontact`)) as total FROM contacts c';
  127.         // pas les éditeurs
  128.         $query ' LEFT JOIN texts t
  129.                 ON  c.`idcontact`=t.`idcontact_publisher`
  130.                 WHERE t.`idcontact_publisher` IS NULL ';
  131.         $total_contacts $contacts->queryOne($query_count.$query);
  132.         $this->view->nb_contacts $total_contacts;
  133.         // si recherche alphabétique
  134.         if (!empty($alpha)) {
  135.             // the lettre
  136.             $this->view->alpha strtoupper($alpha);
  137.             // recherche alpha
  138.             if (!empty($alpha)) {
  139.                 $query .= ' AND c.`organisation` REGEXP \'^'.$alpha.'\' ';
  140.             }
  141.             $query .= ' ORDER BY c.`organisation`';
  142.             //setDebug($query_normal.$query);
  143.             $contacts->query($query_normal.$query);
  144.             while($contacts->fetch()) {
  145.                 $contacts_infos = array(
  146.                     'organisation' => $contacts->cutSentence($contacts->organisation,40),
  147.                     'city' => $contacts->city,
  148.                     'country' => $contacts->getNameCountry($contacts->country,$lng),
  149.                     'url_clean' => $contacts->url_clean,
  150.                 );
  151.                 // on sépare FR et Inter
  152.                 if ($contacts->country=='FR') {
  153.                     $liste_contacts_alpha_fr[$contacts->idcontact] = $contacts_infos;
  154.                 } else {
  155.                     $liste_contacts_alpha_int[$contacts->idcontact] = $contacts_infos;
  156.                 }
  157.                 // tableau avec tous
  158.                 $liste_contacts_alpha[$contacts->idcontact] = $contacts_infos;
  159.             }
  160.             $contacts->free();
  161.             //setDebug(print_r($liste_contacts_alpha,true));
  162.             // liste des contacts à la vue
  163.             if (!empty($liste_contacts_alpha)) {
  164.                 if (!empty($liste_contacts_alpha_fr)) $this->view->liste_contacts_fr $liste_contacts_alpha_fr;
  165.                 if (!empty($liste_contacts_alpha_int)) $this->view->liste_contacts_int $liste_contacts_alpha_int;
  166.             } else {
  167.                 $this->view->no_contact_alpha true;
  168.             }
  169.             $this->view->alpha_search true;
  170.         }
  171.         // moteur de recherche contacts
  172.         if ((isset($this->context['formAsideSearch']) && $this->context['formAsideSearch']->isSubmitted()) || isset($_GET['page']) || !empty($_GET['area']) || !empty($_POST['area'])) {
  173.             $this->view->liste_contacts = array();
  174.             $sql_count 'SELECT COUNT(DISTINCT(c.`idcontact`)) as total ';
  175.             $sql_normal 'SELECT c.`idcontact`,c.`url_clean`,c.`city`,c.`organisation`,c.`idtypestructure`,cty.`'.$GLOBALS['lng'].'`,ts.`typestructure` ';
  176.             $sql 'FROM contacts c
  177.             LEFT JOIN countries cty ON c.`country`=cty.`id`
  178.             INNER JOIN typesstructures ts ON ts.`idtypestructure`=c.`idtypestructure`
  179.             WHERE c.`type`=1 ';
  180.             //AND c.`idcontact` IN ('.join(',',$cont).') ORDER BY c.organisation';
  181.             //echo $sql_normal.$sql;
  182.             // recherche par région
  183.             $area null;
  184.             if (!empty($_REQUEST['area']) && (is_numeric($_REQUEST['area']) || strlen($_REQUEST['area'])<3)) {
  185.                 $area $_REQUEST['area'];
  186.             }
  187.             $this->view->area $area;
  188.             if (!empty($area)) {
  189.                 if ($regions->my_is_int($area)) {
  190.                     $sql_area = ($sqlZipCode $regions->getZipCode($area'c')) ? ' AND'.$sqlZipCode '';
  191.                     $this->view->region_name $regions->getRegionName($area);
  192.                 } else {
  193.                     $this->view->country_name $contacts->getNameCountry($area);
  194.                     $sql_area ' AND c.`country`=\''.$contacts->escape($area).'\' ';
  195.                 }
  196.                 $sql .= $sql_area;
  197.             }
  198.             // recherche par nom de structure
  199.             $organisation null;
  200.             if (!empty($_REQUEST['organisation'])) {
  201.                 $organisation filter_var($_REQUEST['organisation'], FILTER_SANITIZE_STRING);
  202.             }
  203.             // recherche par type de structure
  204.             $idtypestructure null;
  205.             if (!empty($_REQUEST['idtypestructure']) && array_key_exists($_REQUEST['idtypestructure'], $typesstructure_list)) {
  206.                 $idtypestructure filter_var($_REQUEST['idtypestructure'], FILTER_SANITIZE_STRING);
  207.                 $sql .= ' AND c.`idtypestructure` LIKE \''.$contacts->escape($idtypestructure).'%\' ';
  208.                 foreach(array('typestructure','typestructure_pluriel') as $s) {
  209.                     $typesstructure_list_simple[$s] = strtolower($typesstructure_list[$idtypestructure][$s]);
  210.                 }
  211.                 $typesstructure_list_simple['idtypestructure'] = $idtypestructure;
  212.                 $this->view->typestructure $typesstructure_list_simple;
  213.                 if ($idtypestructure=='EC') {
  214.                     $this->view->view_ec true;
  215.                 }
  216.             }
  217.             $this->view->idtypestructure $idtypestructure;
  218.             // recherche
  219.             foreach(array('organisation','city','zip') as $f) {
  220.                 $value $this->context['formAsideSearch']->get($f)->getData();
  221.                 if (empty($value) && isset($_GET[$f])) {
  222.                     $value strip_tags(trim(htmlspecialchars($_GET[$f])));
  223.                 }
  224.                 if (!empty($value)) {
  225.                     $sql .= ' AND c.`'.$f.'` LIKE \'%'.$contacts->escape($value).'%\' ';
  226.                     $this->view->$f $value;
  227.                 }
  228.             }
  229.             $sql .= ' ORDER BY c.organisation';
  230.             // nb resultat par page
  231.             $pagerOptions['perPage'] = 20;
  232.             // nombre d'enregistrement
  233.             $totalItems $contacts->queryOne($sql_count.$sql);
  234.             //setDebug($sql_count.$sql);
  235.             if (!empty($totalItems) && $totalItems>0) {
  236.                 // image du pager
  237.                 $pagerOptions['totalItems'] = $totalItems;
  238.                 // pagination
  239.                 $pagerOptions['delta'] = 2;
  240.                 $this->perPage $pagerOptions['perPage'] = 30;
  241.                 $this->view->pagination $this->getPagination($totalItems);
  242.                 // ajout des criteres de tri apres avoir fait le count
  243.                 if (isset($tri)) {
  244.                     $sql .= $tri;
  245.                 }
  246.                 //limite
  247.                 $limit $contacts->dbLimit($this->perPage$this->getLimitStart());
  248.                 $contacts->query($sql_normal.$sql.$limit);
  249.                 //setDebug($sql_normal.$sql.$limit);
  250.                 while($contacts->fetch()) {
  251.                     $idcontact $contacts->idcontact;
  252.                     $liste_contacts[$idcontact] = array(
  253.                         'organisation' => $contacts->organisation,
  254.                         'subtitle' => 'nom_suite',
  255.                         'country' => $contacts->fr,
  256.                         'url_clean' => $contacts->url_clean,
  257.                         'city' => $contacts->city,
  258.                         'typestructure' => $contacts->typestructure,
  259.                         'idtypestructure' => $contacts->idtypestructure,
  260.                     );
  261.                     if (in_array($contacts->idtypestructure$selected_types)) {
  262.                         $liste_contacts[$idcontact]['selected_type'] = true;
  263.                     }
  264.                 }
  265.                 //passer les resultats au template
  266.                 if (!empty($liste_contacts)) {
  267.                     $this->view->liste_contacts $liste_contacts;
  268.                 }
  269.                 $urlpagination = new asidesUrlPagination(
  270.                     '/contacts/generate_params',
  271.                     array(
  272.                         'recherche' => true,
  273.                         'areac' => $this->context['view']->area,
  274.                         'city' => $this->context['formAsideSearch']->get('city')->getData(),
  275.                         'organisation' => $organisation,
  276.                         'structure' => $this->view->idtypestructure
  277.                     ),
  278.                     $this->context
  279.                 );
  280.                 $this->view->pagination['url_custom'] = $urlpagination->url_pagination();
  281.             }
  282.             $this->view->resultat true;
  283.         }
  284.         // titre de la page
  285.         $this->title_page 'Les lieux de diffusion et les structures théâtrales (compagnie...)';
  286.         // situation
  287.         $this->view->locate = array(=> 'Lieux de diffusion, compagnie et structures théâtrales');
  288.         $this->rub_courante 'contacts';
  289.         // jajascript
  290.         $this->context['view']->carte_version 'svg';
  291.         $this->context['view']->is_carte_svg true;
  292.         $this->context['view']->js_more['raphael-min-js'] = 'raphaeljs/raphael-min.js';
  293.         $this->context['view']->js_more['raphael-svg-import'] = 'raphaeljs/raphael-svg-import.js';
  294.         //asides_body
  295.         $asides_body = new asides();
  296.         $asides_body->load('contact_rechercher');
  297.         $this->context['view']->aside_body $asides_body->view($this->context['view']);
  298.         //asides_top
  299.         $asides_top = new asides();
  300.         $asides_top->load(['aside_top' => array(
  301.             'php' => array(
  302.                 'method' => 'asidesUrlRegions'
  303.             )
  304.         )]);
  305.         $this->context['view']->aside_top $asides_top->view($this->context['view']);
  306.         $recherche_dans_region = array(
  307.             '' => array(
  308.                 'name' => 'Une structure',
  309.                 'url' => '/contacts/generate_params',
  310.                 'key_2' => 'null'
  311.             ),
  312.             'TN' => array(
  313.                 'name' => 'Les théâtres nationaux',
  314.                 'key_url' => 'TN'
  315.             ),
  316.             'CDN' => array(
  317.                 'name' => 'Les centres dramatiques',
  318.                 'key_url' => 'CDN'
  319.             ),
  320.             'SN' => array(
  321.                 'name' => 'Les scènes nationales',
  322.                 'key_url' => 'SN'
  323.             ),
  324.         );
  325.         //on supprime les théâtres nationaux partout sauf dans les régins 1 et 8
  326.         if (isset($this->context['view']->area) && !in_array($this->context['view']->area, [1,8])){
  327.             unset($recherche_dans_region['TN']);
  328.         }
  329.         //On affiche la publicité google
  330.         $asides_publicite = new asides();
  331.         asides::setEntityManager($this->em);
  332.         asides::loadaside('Publicite')->addGoogle($asides_publicite$this->serviceAbonnements);
  333.         $this->context['view']->asides_publicite $asides_publicite->view($this->context['view']);
  334.         //asides
  335.         $asides = new asides();
  336.         $asides->load(['url_lists_alone,recherche_dans_region' => array(
  337.             'php' => [
  338.                 'method' => 'asidesUrlLists',
  339.                 'urls' => $recherche_dans_region,
  340.                 'url' => '/contacts/structures/liste/generate_params',
  341.                 'params' => array(
  342.                     'activate' => (isset($idtypestructure)) ? $idtypestructure 'null',
  343.                 ),
  344.                 'structure' => array(
  345.                     'structure_classic' => array(
  346.                         'area' => (isset($this->context['view']->area)) ? $this->context['view']->area null,
  347.                         'idtypestructure' => 'key_url'
  348.                     )
  349.                 )
  350.             ],
  351.             'title' => 'Rechercher'
  352.         )]);
  353.         $asides->load(['url_lists_alone,programme_pdf' => array(
  354.             'php' => [
  355.                 'method' => 'asidesUrlLists',
  356.                 'urls' => ['programmes' => array(
  357.                     'name' => 'Tous les programmes'
  358.                 )
  359.                 ],
  360.                 'url' => '/contacts/archives/programmes/generate_params',
  361.                 'params' => array(
  362.                     'key_url' => (isset($idtypestructure)) ? $idtypestructure 'ALL',
  363.                     'key_area' => (isset($this->context['view']->area)) ? $this->context['view']->area null,
  364.                 ),
  365.                 'structure' => array(
  366.                     'area' => 'key_area',
  367.                     'structure_classic' => array(
  368.                         'idtypestructure' => 'key_url'
  369.                     )
  370.                 )
  371.             ],
  372.             'title' => 'Programme en PDF'
  373.         )]);
  374.         //Chargement de la pub par région
  375.         $params_pub = array();
  376.         if (!empty($this->context['view']->area)){
  377.             $params_pub = ['region' => $this->context['view']->area];
  378.         }
  379.         asides::setEntityManager($this->em);
  380.         asides::loadaside('Publicite')->addWithRegion($asides$params_pub); //$this->area
  381.         $asides->load(['common_carte' => array(
  382.             'php' => array(
  383.                 'method' => 'asidesUrlLists',
  384.                 'url' => '/contacts/generate_params',
  385.                 'params' => array(
  386.                     'get_id' => 'get_id',
  387.                     'key_type' => (isset($idtypestructure)) ? $idtypestructure 'ALL',
  388.                 ),
  389.                 'structure' => array(
  390.                     'structure_classic' => array(
  391.                         'area' => 'get_id',
  392.                         'idtypestructure' => 'key_type',
  393.                     )
  394.                 )
  395.             )
  396.         )]);
  397.         asides::setEntityManager($this->em);
  398.         asides::loadaside('Publicite')->addWithNational($asides);
  399.         $asides->load('contact_ajouter_structure');
  400.         $asides->load(['common_participer' => array(
  401.             'php' => array(
  402.                 'method' => 'asidesUrlLists_Ajoutez',
  403.             )
  404.         )]);
  405.         $this->context['view']->aside $asides->view($this->context['view']);
  406.         return $this->view('contacts/view.html.twig');
  407.     }
  408.     /**
  409.      * @Route("/contacts/structures/partenaires", name="contacts_partenaires")
  410.      * @Route("/contacts/structures/partenaires/classification/{classification}", name="contacts_partenaires_classification")
  411.      */
  412.     public function action_partenaires($classification null)
  413.     {
  414.         $this->view->action $this->context['view']->action 'partenaires';
  415.         $params['classification'] = $classification;
  416.         $contacts $this->em->getRepository(Contacts::class);
  417.         $classifications_contact $this->em->getRepository(Classifications::class)->getClassificationsInGroup(10);
  418.         if (!empty($params['classification'])) {
  419.             foreach($classifications_contact as $k=>$v) {
  420.                 if ($v['classification']==$params['classification']) {
  421.                     $idclassification $v['idclassification'];
  422.                     break;
  423.                 }
  424.             }
  425.         }
  426.         // TN par défaut
  427.         if (empty($idclassification)) {
  428.             $idclassification 128;
  429.         }
  430.         $params_sql_typestructure = array(
  431.             'direction' => 'ASC',
  432.             'idclassification' => array($idclassification),
  433.             'limit' => array(0,300),
  434.             'dbg' => array('structures','Contacts avec une classification précise'),
  435.         );
  436.         $structures $contacts->getListContacts($params_sql_typestructure,array(),array('get_profile_picture' => true));
  437.         $this->context['view']->typestructure $this->context['tr']->trans($params['classification']);
  438.         $this->context['view']->structures $structures;
  439.         // titre de la page
  440.         $this->view->title_page $this->context['tr']->trans($params['classification']).' partenaires';
  441.         // situation
  442.         $this->view->locate = array(
  443.             '/contacts/' => 'Structures',
  444.             => $this->context['tr']->trans($params['classification']).' partenaires',
  445.         );
  446.         $rub_courante 'contacts';
  447.         // style en plus
  448.         $this->context['view']->style_more = array(
  449.             'dossier',
  450.             'rubrique',
  451.             'pageregion'
  452.         );
  453.         // asides top
  454.         $asides_top = new asides();
  455.         $asides_top->load(['aside_top' => array(
  456.             'php' => array(
  457.                 'method' => 'asidesUrlListsMenuCDN',
  458.             )
  459.         )
  460.         ]);
  461.         $this->context['view']->aside_top $asides_top->view($this->context['view']);
  462.         $nav_partenaires = array(
  463.             array(
  464.                 'name' => 'Théâtres nationaux',
  465.                 'key_sub' => 'class_home_tn'
  466.             ),
  467.             array(
  468.                 'name' => 'Centres dramatiques',
  469.                 'key_sub' => 'class_home_cdncdr'
  470.             ),
  471.             array(
  472.                 'name' => 'Scènes nationales',
  473.                 'key_sub' => 'class_home_sn'
  474.             ),
  475.             array(
  476.                 'name' => 'Autres théâtres',
  477.                 'key_sub' => 'class_home_autres'
  478.             ),
  479.             array(
  480.                 'name' => 'Belgique',
  481.                 'key_sub' => 'class_home_belgique'
  482.             ),
  483.             array(
  484.                 'name' => 'Suisse',
  485.                 'key_sub' => 'class_home_suisse'
  486.             ),
  487.             array(
  488.                 'name' => 'Festivals de théâtre',
  489.                 'key_sub' => 'class_home_festival'
  490.             ),
  491.         );
  492.         $nav_partenaires_infos = array(
  493.             array(
  494.                 'name' => 'Théâtres nationaux',
  495.                 'url' => '/contacts/structures/liste?idtypestructure=TN'
  496.             ),
  497.             array(
  498.                 'name' => 'Centres dramatiques',
  499.                 'url' => '/contacts/structures/liste?idtypestructure=CDN'
  500.             ),
  501.             array(
  502.                 'name' => 'Scènes nationales',
  503.                 'url' => '/contacts/structures/liste?idtypestructure=SN'
  504.             ),
  505.             array(
  506.                 'name' => 'Belgique',
  507.                 'url' => '/regions/actualites/area/BE'
  508.             ),
  509.             array(
  510.                 'name' => 'Suisse',
  511.                 'url' => '/regions/actualites/area/CH'
  512.             ),
  513.         );
  514.         $asides = new asides();
  515.         $asides->load(['url_lists_alone' => array(
  516.             'title' => 'Les partenaires',
  517.             'php' => array(
  518.                 'method' => 'asidesUrlLists',
  519.                 'urls' => $nav_partenaires,
  520.                 'url' => '/contacts/structures/partenaires/classification/key_sub',
  521.                 'params' => array(
  522.                     'activate' => $this->context['view']->typestructure
  523.                 )
  524.             )
  525.         )]);
  526.         $asides->load(['url_lists_alone, nav_partenaires_infos' => array(
  527.             'php' => array(
  528.                 'method' => 'asidesUrlLists',
  529.                 'urls' => $nav_partenaires_infos,
  530.                 'params' => array(
  531.                     'activate' => ''
  532.                 )
  533.             ),
  534.             'title' => 'Toutes les infos'
  535.         )]);
  536.         $this->context['view']->aside $asides->view($this->context['view']);
  537.         return $this->view('contacts/partenaires.html.twig');
  538.     }
  539.     /**
  540.      * @Route("/contacts/structures/liste", name="contacts_liste")
  541.      */
  542.     public function action_liste()
  543.     {
  544.         $this->view->action $this->context['view']->action 'liste';
  545.         $contacts $this->em->getRepository(Contacts::class);
  546.         // type de structure
  547.         $typesstructures $this->em->getRepository(Typesstructures::class);
  548.         $typesstructure_list $typesstructures->getTypeStructureList(true,true);
  549.         //setDebug(print_r($typesstructure_list,true));
  550.         // type de structure recherchée
  551.         if (!empty($_REQUEST['idtypestructure']) && array_key_exists($_REQUEST['idtypestructure'], $typesstructure_list)) {
  552.             $idtypestructure filter_var($_REQUEST['idtypestructure'], FILTER_SANITIZE_STRING);
  553.         } else {
  554.             $idtypestructure 'SN';
  555.         }
  556.         if ($idtypestructure=='SN') {
  557.             $this->view->view_sn true;
  558.         }
  559.         foreach(array('typestructure','typestructure_pluriel') as $s) {
  560.             if (!empty($typesstructure_list[$idtypestructure])){
  561.                 $typesstructure_list_simple[$s] = strtolower($typesstructure_list[$idtypestructure][$s]);
  562.             }
  563.         }
  564.         $typesstructure_list_simple['idtypestructure'] = $idtypestructure;
  565.         $this->view->typestructure $typesstructure_list_simple;
  566.         // choix du type
  567.         $typesstructure_list_select[0] = 'Choisissez dans la liste...';
  568.         foreach($typesstructure_list as $k=>$v) {
  569.             $typesstructure_list_select[$k] = $v['typestructure_pluriel'];
  570.         }
  571.         //$form->addElement('select', 'idtypestructure', 'Type de structure', $typesstructure_list_select, array('id' => 'idtypestructure'));
  572.         $params_sql_typestructure = array(
  573.             'where' => array(
  574.                 array('contacts''idtypestructure'$idtypestructure),
  575.                 array('contacts''country''FR'),
  576.                 ' AND contacts.idcontact NOT IN (SELECT idcontact FROM contact_classification WHERE idclassification=99) ',
  577.             ),
  578.             'order' => array('contacts' => 'organisation'),
  579.             'direction' => 'ASC',
  580.             'idclassification' => array('NOT' => array(99)),
  581.             'limit' => array(0,300),
  582.             'dbg' => array('structures','Contacts avec un type précis'),
  583.         );
  584.         // pour le HETS
  585.         if ($idtypestructure=='EC') {
  586.             unset($params_sql_typestructure['where'][1]);
  587.         }
  588.         $structures $contacts->getListContacts($params_sql_typestructure,array(),array('get_profile_picture' => true));
  589.         $this->view->nb_structures count($structures);
  590.         $this->view->structures $structures;
  591.         // titre de la page
  592.         $this->title_page $typesstructure_list[$idtypestructure]['typestructure_pluriel'];
  593.         $this->rub_courante 'contacts';
  594.         // ajouter masonery
  595.         $this->context['view']->js_more[] = 'jquery.masonry.min.js';
  596.         $this->context['view']->use_addthis true;
  597.         $asides_top = new asides();
  598.         $asides_top->load(['aside_top' => array(
  599.             'php' => array(
  600.                 'method' => 'asidesUrlListsMenuCDN'
  601.             )
  602.         )
  603.         ]);
  604.         $this->context['view']->aside_top $asides_top->view($this->context['view']);
  605.         $asides = new asides();
  606.         $asides->load(['common_carte' => array(
  607.             'url' => '/contacts/?area=get_id'
  608.         )]);
  609.         if ($idtypestructure == 'CDN'){
  610.             $asides->load('contact_acdn');
  611.         }
  612.         $asides->load(['url_lists_alone,tn_cdn_sn' => array(
  613.             'php' => [
  614.                 'method' => 'tn_cdn_sn',
  615.                 'url' => '/key_controller/structures/liste?idtypestructure=key_structure',
  616.                 'params' => array(
  617.                     'activate' => $this->context['view']->typestructure['idtypestructure']
  618.                 )
  619.             ],
  620.             'title' => 'Voir aussi'
  621.         )]);
  622.         $this->context['view']->aside $asides->view($this->context['view']);
  623.         // situation
  624.         $this->view->locate = array(
  625.             '/contacts/' => 'Structures',
  626.             => $typesstructure_list[$idtypestructure]['typestructure_pluriel'],
  627.         );
  628.         return $this->view('contacts/liste.html.twig');
  629.     }
  630. }