src/Controller/BaseController.php line 196

Open in your IDE?
  1. <?php
  2. // src/Controller/BaseController.php
  3. namespace App\Controller;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Component\DependencyInjection\ContainerInterface;
  10. class BaseController extends AbstractController
  11. {
  12.     const ACCESS_GLOBAL 'ROLE_USER';
  13.     protected $params = [
  14.         'page' => [
  15.             'head' => [
  16.                 'title' => 'Gestion de Planning',
  17.                 'description' => '',
  18.                 'canonical' => '',
  19.                 'robots' => 'noindex, nofollow',
  20.                 'sitemap' => '',
  21.             ],
  22.             'header' => [
  23.                 'title' => 'Outil de gestion de Planning',
  24.                 'subtitle' => 'Alors Formations',
  25.                 'description' => '',
  26.             ],
  27.             'footer' => [
  28.                 'external_links' => [
  29.                     'alors' => [
  30.                         'url' => 'https://www.alors-formation.com/',
  31.                         'label' => 'Alors Formation',
  32.                     ],
  33.                     'catalogue' => [
  34.                         'url' => 'https://alors-formation.catalogueformpro.com/',
  35.                         'label' => 'Catalogue',
  36.                     ],
  37.                     'linkedin' => [
  38.                         'url' => 'https://www.linkedin.com/company/alors-formation',
  39.                         'label' => 'LinkedIn',
  40.                     ],
  41.                     'digiforma' => [
  42.                         'url' => 'https://app.digiforma.com/session/signin',
  43.                         'label' => 'DigiForma',
  44.                     ],
  45.                 ],
  46.                 'contact' => [
  47.                     'email' => 'contact@alors-formation.com',
  48.                     'tel' => '+33 4 75 80 15 49',
  49.                 ],
  50.             ],
  51.             'class' => '',
  52.             'menu' => [
  53.                 'list' => [
  54.                     'entreprise' => [
  55.                         'route' => 'entreprise_list',
  56.                         'label' => 'Entreprises',
  57.                     ],
  58.                     'apprenant' => [
  59.                         'route' => 'apprenant_list',
  60.                         'label' => 'Apprenants',
  61.                     ],
  62.                     'customer' => [
  63.                         'route' => 'customer_list',
  64.                         'label' => 'Clients',
  65.                     ],
  66.                     'intervenant' => [
  67.                         'route' => 'intervenant_list',
  68.                         'label' => 'Intervenants',
  69.                     ],
  70.                     'session' => [
  71.                         'route' => 'session_list',
  72.                         'label' => 'Sessions',
  73.                     ],
  74.                     'cerfa' => [
  75.                         'route' => 'apprenant_cerfa_list',
  76.                         'label' => 'CERFA',
  77.                         'role' => 'ROLE_CERFA',
  78.                     ],
  79.                                         'planning' => [
  80.                                                 'route' => 'session_planning',
  81.                         'label' => 'Planning',
  82.                         'role' => 'ROLE_PLANNING',
  83.                                         ],
  84.                     'sms' => [
  85.                         'route' => 'session_sms',
  86.                         'label' => 'SMS',
  87.                         //'role' => 'ROLE_CERFA',
  88.                     ],
  89.                     'synchro' => [
  90.                         'route' => 'api_sync_all',
  91.                         'label' => 'Synchro',
  92.                         //'click_confirm' => 'Êtes-vous certain ?',
  93.                     ],
  94.                 ],
  95.             ],
  96.             'menu_admin' => [
  97.                 'role' => 'ROLE_ADMIN',
  98.                 'list' => [
  99.                     'salle' => [
  100.                         'route' => 'salle_list',
  101.                         'label' => 'Salles',
  102.                     ],
  103.                     'session_creneau' => [
  104.                         'route' => 'session_creneau_list',
  105.                         'label' => 'Créneaux',
  106.                     ],
  107.                     'financeur' => [
  108.                         'route' => 'financeur_list',
  109.                         'label' => 'Financeurs',
  110.                     ],
  111.                     'formation_programme' => [
  112.                         'route' => 'formation_programme_list',
  113.                         'label' => 'Programmes',
  114.                     ],
  115.                     'formation_module' => [
  116.                         'route' => 'formation_module_list',
  117.                         'label' => 'Modules',
  118.                     ],
  119.                     'facture' => [
  120.                         'route' => 'facture_list',
  121.                         'label' => 'Factures',
  122.                     ],
  123.                     'facturesync' => [
  124.                         'route' => 'facturesync_list',
  125.                         'label' => 'Analyse Factures',
  126.                     ],
  127.                     'user' => [
  128.                         'route' => 'user_list',
  129.                         'label' => 'Utilisateurs',
  130.                     ],
  131.                 ],
  132.             ],
  133.             'menu_superadmin' => [
  134.                 'role' => 'ROLE_SUPERADMIN',
  135.                 'list' => [
  136.                     'userrole' => [
  137.                         'route' => 'userrole_list',
  138.                         'label' => 'Roles Utilisateurs',
  139.                     ],
  140.                     'user_type' => [
  141.                         'route' => 'usertype_list',
  142.                         'label' => 'Types Utilisateurs',
  143.                     ],
  144.                     'structure' => [
  145.                         'route' => 'structure_list',
  146.                         'label' => 'Structures/Environnements',
  147.                     ],
  148.                     'lieu' => [
  149.                         'route' => 'lieu_list',
  150.                         'label' => 'Lieux',
  151.                     ],
  152.                     'formation' => [
  153.                         'route' => 'formation_list',
  154.                         'label' => 'Formations',
  155.                     ],
  156.                     'creneau' => [
  157.                         'route' => 'creneau_list',
  158.                         'label' => 'Créneaux Type',
  159.                     ],
  160.                     'param' => [
  161.                         'route' => 'param_list',
  162.                         'label' => 'Paramètres',
  163.                     ],
  164.                     'digiaccount' => [
  165.                         'route' => 'digiaccount_list',
  166.                         'label' => 'Comptes DigiForma',
  167.                     ],
  168.                 ],
  169.             ],
  170.             'breadcrumbs' => [],
  171.             // Contents
  172.             'title' => 'Outil de gestion de Planning',
  173.             'subtitle' => 'Alors Formations',
  174.             'description' => '',
  175.             'contents' => '',
  176.         ],
  177.     ];
  178.     protected $container;
  179.     protected $em;
  180.     public function __construct(ContainerInterface $containerEntityManagerInterface $em)
  181.     {
  182.         //$api_token = $container->getParameter('DIGIFORMA_API_TOKEN');
  183.         //var_dump($api_token); die();
  184.         $this->container $container;
  185.         $this->em $em;
  186.         // Auth
  187.         if (!$this->isGranted('ROLE_ADMIN'))
  188.             $this->denyAccessUnlessGranted(static::ACCESS_GLOBAL);
  189.         $this->params['authorization_checker'] = $this->container->get('security.authorization_checker');
  190.     }
  191.     public function getContainer()
  192.     {
  193.         return $this->container;
  194.     }
  195.     public function calendar($yearmonth_debut$yearmonth_fin)
  196.     {
  197.         $ym $yearmonth_debut;
  198.         $y substr($ym04);
  199.         $m substr($ym52);
  200.         $days = [];
  201.         // Mois
  202.         while($ym <= $yearmonth_fin) {
  203.             $m++;
  204.             if ($m>12) {
  205.                 $m 1;
  206.                 $y++;
  207.             }
  208.             $m_days cal_days_in_month(CAL_GREGORIAN$m$y);
  209.             if ($m<10$m '0'.$m;
  210.             $ym $y.'-'.$m;
  211.             for ($i=1$i<=$m_days$i++) {
  212.                 if ($i<10$i '0'.$i;
  213.                 $d $y.'-'.$m.'-'.$i;
  214.                 $dt strtotime($d);
  215.                 $days[$d] = ['date'=>$d'month'=>$m'num'=>$i'wd'=>date('w'$dt), 'c'=>[]];
  216.                 //$days[] = ['num'=>$i];
  217.             }
  218.         }
  219.         return $days;
  220.     }
  221. }