<?php
// src/Controller/BaseController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BaseController extends AbstractController
{
const ACCESS_GLOBAL = 'ROLE_USER';
protected $params = [
'page' => [
'head' => [
'title' => 'Gestion de Planning',
'description' => '',
'canonical' => '',
'robots' => 'noindex, nofollow',
'sitemap' => '',
],
'header' => [
'title' => 'Outil de gestion de Planning',
'subtitle' => 'Alors Formations',
'description' => '',
],
'footer' => [
'external_links' => [
'alors' => [
'url' => 'https://www.alors-formation.com/',
'label' => 'Alors Formation',
],
'catalogue' => [
'url' => 'https://alors-formation.catalogueformpro.com/',
'label' => 'Catalogue',
],
'linkedin' => [
'url' => 'https://www.linkedin.com/company/alors-formation',
'label' => 'LinkedIn',
],
'digiforma' => [
'url' => 'https://app.digiforma.com/session/signin',
'label' => 'DigiForma',
],
],
'contact' => [
'email' => 'contact@alors-formation.com',
'tel' => '+33 4 75 80 15 49',
],
],
'class' => '',
'menu' => [
'list' => [
'entreprise' => [
'route' => 'entreprise_list',
'label' => 'Entreprises',
],
'apprenant' => [
'route' => 'apprenant_list',
'label' => 'Apprenants',
],
'customer' => [
'route' => 'customer_list',
'label' => 'Clients',
],
'intervenant' => [
'route' => 'intervenant_list',
'label' => 'Intervenants',
],
'session' => [
'route' => 'session_list',
'label' => 'Sessions',
],
'cerfa' => [
'route' => 'apprenant_cerfa_list',
'label' => 'CERFA',
'role' => 'ROLE_CERFA',
],
'planning' => [
'route' => 'session_planning',
'label' => 'Planning',
'role' => 'ROLE_PLANNING',
],
'sms' => [
'route' => 'session_sms',
'label' => 'SMS',
//'role' => 'ROLE_CERFA',
],
'synchro' => [
'route' => 'api_sync_all',
'label' => 'Synchro',
//'click_confirm' => 'Êtes-vous certain ?',
],
],
],
'menu_admin' => [
'role' => 'ROLE_ADMIN',
'list' => [
'salle' => [
'route' => 'salle_list',
'label' => 'Salles',
],
'session_creneau' => [
'route' => 'session_creneau_list',
'label' => 'Créneaux',
],
'financeur' => [
'route' => 'financeur_list',
'label' => 'Financeurs',
],
'formation_programme' => [
'route' => 'formation_programme_list',
'label' => 'Programmes',
],
'formation_module' => [
'route' => 'formation_module_list',
'label' => 'Modules',
],
'facture' => [
'route' => 'facture_list',
'label' => 'Factures',
],
'facturesync' => [
'route' => 'facturesync_list',
'label' => 'Analyse Factures',
],
'user' => [
'route' => 'user_list',
'label' => 'Utilisateurs',
],
],
],
'menu_superadmin' => [
'role' => 'ROLE_SUPERADMIN',
'list' => [
'userrole' => [
'route' => 'userrole_list',
'label' => 'Roles Utilisateurs',
],
'user_type' => [
'route' => 'usertype_list',
'label' => 'Types Utilisateurs',
],
'structure' => [
'route' => 'structure_list',
'label' => 'Structures/Environnements',
],
'lieu' => [
'route' => 'lieu_list',
'label' => 'Lieux',
],
'formation' => [
'route' => 'formation_list',
'label' => 'Formations',
],
'creneau' => [
'route' => 'creneau_list',
'label' => 'Créneaux Type',
],
'param' => [
'route' => 'param_list',
'label' => 'Paramètres',
],
'digiaccount' => [
'route' => 'digiaccount_list',
'label' => 'Comptes DigiForma',
],
],
],
'breadcrumbs' => [],
// Contents
'title' => 'Outil de gestion de Planning',
'subtitle' => 'Alors Formations',
'description' => '',
'contents' => '',
],
];
protected $container;
protected $em;
public function __construct(ContainerInterface $container, EntityManagerInterface $em)
{
//$api_token = $container->getParameter('DIGIFORMA_API_TOKEN');
//var_dump($api_token); die();
$this->container = $container;
$this->em = $em;
// Auth
if (!$this->isGranted('ROLE_ADMIN'))
$this->denyAccessUnlessGranted(static::ACCESS_GLOBAL);
$this->params['authorization_checker'] = $this->container->get('security.authorization_checker');
}
public function getContainer()
{
return $this->container;
}
public function calendar($yearmonth_debut, $yearmonth_fin)
{
$ym = $yearmonth_debut;
$y = substr($ym, 0, 4);
$m = substr($ym, 5, 2);
$days = [];
// Mois
while($ym <= $yearmonth_fin) {
$m++;
if ($m>12) {
$m = 1;
$y++;
}
$m_days = cal_days_in_month(CAL_GREGORIAN, $m, $y);
if ($m<10) $m = '0'.$m;
$ym = $y.'-'.$m;
for ($i=1; $i<=$m_days; $i++) {
if ($i<10) $i = '0'.$i;
$d = $y.'-'.$m.'-'.$i;
$dt = strtotime($d);
$days[$d] = ['date'=>$d, 'month'=>$m, 'num'=>$i, 'wd'=>date('w', $dt), 'c'=>[]];
//$days[] = ['num'=>$i];
}
}
return $days;
}
}