depot v2
This commit is contained in:
97
src/schedule-2.0/src/Command/AppInitCommand.php
Normal file
97
src/schedule-2.0/src/Command/AppInitCommand.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
|
||||
use App\Entity\User;
|
||||
|
||||
|
||||
class AppInitCommand extends Command
|
||||
{
|
||||
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
private $filesystem;
|
||||
private $rootlog;
|
||||
|
||||
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->container = $container;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('app:AppInit')
|
||||
->setDescription('Init Data for App')
|
||||
->setHelp('This command Init Data App')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->rootlog = $this->container->get('kernel')->getProjectDir()."/../var/log/";
|
||||
|
||||
$output->writeln('APP = Default Data');
|
||||
|
||||
$this->insertUser("admin","admin");
|
||||
|
||||
$output->writeln('');
|
||||
|
||||
return $this->em->flush();
|
||||
}
|
||||
|
||||
protected function insertUser() {
|
||||
$metadata = $this->em->getClassMetaData('App:User');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
|
||||
|
||||
// Job Récupératoin la table de référence des articles
|
||||
// Toute les 1mn
|
||||
$entity = $this->em->getRepository('App:User')->findOneBy(["username"=>"admin"]);
|
||||
if(!$entity) {
|
||||
$this->writelnred('Création du compte admin par défaut avec password admin - Veuillez modifier votre password admin après connexion');
|
||||
$entity = new User;
|
||||
$entity->setId(0);
|
||||
$entity->setUsername("admin");
|
||||
$entity->setPassword("admin");
|
||||
$entity->setFirstname("schedule");
|
||||
$entity->setLastname("admin");
|
||||
$entity->setEmail("admin@noreply@com");
|
||||
$entity->setRoles(["ROLE_ADMIN"]);
|
||||
$entity->setAvatar("admin.jpg");
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
|
||||
// On flush
|
||||
$this->em->flush();
|
||||
|
||||
}
|
||||
|
||||
private function writelnred($string) {
|
||||
$this->output->writeln('<fg=red>'.$string.'</>');
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
private function writeln($string) {
|
||||
$this->output->writeln($string);
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
}
|
165
src/schedule-2.0/src/Command/CronCommand.php
Normal file
165
src/schedule-2.0/src/Command/CronCommand.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Command\LockableTrait;
|
||||
|
||||
use App\Entity\Cron;
|
||||
|
||||
class CronCommand extends Command
|
||||
{
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
private $filesystem;
|
||||
private $rootlog;
|
||||
use LockableTrait;
|
||||
|
||||
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->container = $container;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('app:Cron')
|
||||
->setDescription('Execution of the cron command')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->rootlog = $this->container->get('kernel')->getProjectDir()."/../var/log/";
|
||||
|
||||
$appCron = $this->container->getParameter('appCron');
|
||||
if(!$appCron)
|
||||
{
|
||||
$this->writelnred('CRON désactivé');
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!$this->lock()) {
|
||||
$this->output->writeln("CRON LOCK");
|
||||
return 0;
|
||||
}
|
||||
|
||||
$crons = $this->em->getRepository('App:Cron')->toexec();
|
||||
$i=0;
|
||||
|
||||
if($crons) {
|
||||
$now=new \DateTime();
|
||||
$this->writelnred('');
|
||||
$this->writelnred('');
|
||||
$this->writelnred('');
|
||||
$this->writelnred('');
|
||||
$this->writelnred('==========================================================================================================');
|
||||
$this->writelnred('== CRON ==================================================================================================');
|
||||
$this->writelnred('==========================================================================================================');
|
||||
$this->writeln ('Date = '.$now->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
foreach($crons as $cron) {
|
||||
$i++;
|
||||
|
||||
// Id du cron
|
||||
$idcron = $cron->getId();
|
||||
|
||||
// Flag d'execution en cours
|
||||
$now=new \DateTime();
|
||||
$cron->setStartexecdate($now);
|
||||
//$cron->setStatut(1);
|
||||
$this->em->persist($cron);
|
||||
$this->em->flush();
|
||||
|
||||
// Récupération de la commande
|
||||
$command = $this->getApplication()->find($cron->getCommand());
|
||||
|
||||
// Réccuépration des parametres
|
||||
$jsonparameter=json_decode($cron->getJsonargument(),true);
|
||||
|
||||
// Parametre id du cron actuel
|
||||
$jsonparameter["cronid"]=$cron->getId();
|
||||
|
||||
// Parametre si dernière execution
|
||||
$lastchance=false;
|
||||
if($cron->getRepeatcall()>0)
|
||||
$lastchance=($cron->getRepeatexec()+1==$cron->getRepeatcall());
|
||||
$jsonparameter["lastchance"]=$lastchance;
|
||||
|
||||
// Formater la chaine de parametre
|
||||
$parameter = new ArrayInput($jsonparameter);
|
||||
|
||||
// Executer la commande
|
||||
$returnCode=false;
|
||||
try{
|
||||
$returnCode = $command->run($parameter, $output);
|
||||
|
||||
// Revenir sur le cron encours à cause du clear du manager présent dans la synchro
|
||||
// Sinon le manager se pomme et génère des nouveaux enregistrement plutot que mettre à jour celui en cours
|
||||
$cron=$this->em->getRepository('App:Cron')->find($idcron);
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
$this->writelnred("JOB EN ERREUR");
|
||||
}
|
||||
|
||||
// Flag de fin d'execution
|
||||
$now=new \DateTime();
|
||||
$cron->setEndexecdate($now);
|
||||
|
||||
// Date prochaine execution
|
||||
if($cron->getrepeatinterval()>=0) {
|
||||
// Si interval par heure
|
||||
if(fmod($cron->getRepeatinterval(),3600)==0)
|
||||
$next=clone $cron->getNextexecdate();
|
||||
else
|
||||
$next=new \DateTime();
|
||||
|
||||
$next->add(new \DateInterval('PT'.$cron->getRepeatinterval().'S'));
|
||||
$cron->setNextexecdate($next);
|
||||
}
|
||||
|
||||
// Statut OK/KO/Retry
|
||||
if($returnCode!="retry"||!$returnCode) {
|
||||
$cron->setStatut(2);
|
||||
if($returnCode!=1) {
|
||||
$cron->setStatut(3);
|
||||
if($cron->getRepeatcall()>0) $cron->setRepeatexec($cron->getRepeatexec()+1);
|
||||
}
|
||||
}
|
||||
|
||||
$this->em->persist($cron);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
if($crons) {
|
||||
$this->writelnred("==");
|
||||
$this->writelnred("FIN CRON");
|
||||
$this->writelnred("==");
|
||||
$this->writelnred("");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function writelnred($string) {
|
||||
$this->output->writeln('<fg=red>'.$string.'</>');
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
private function writeln($string) {
|
||||
$this->output->writeln($string);
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
}
|
160
src/schedule-2.0/src/Command/CronInitCommand.php
Normal file
160
src/schedule-2.0/src/Command/CronInitCommand.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
|
||||
use App\Entity\Cron;
|
||||
|
||||
|
||||
class CronInitCommand extends Command
|
||||
{
|
||||
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
private $filesystem;
|
||||
private $rootlog;
|
||||
|
||||
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->container = $container;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('app:CronInit')
|
||||
->setDescription('Init Data for Cron')
|
||||
->setHelp('This command Init Data Cron')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$appCron = $this->container->getParameter('appCron');
|
||||
if(!$appCron)
|
||||
return false;
|
||||
|
||||
$output->writeln('CRON = Default Data');
|
||||
|
||||
$this->insertCron();
|
||||
|
||||
$output->writeln('');
|
||||
|
||||
return $this->em->flush();
|
||||
}
|
||||
|
||||
protected function insertCron() {
|
||||
/*
|
||||
$metadata = $this->em->getClassMetaData('App:Cron');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
|
||||
|
||||
// Job Récupératoin la table de référence des articles
|
||||
// Toute les 1mn
|
||||
$entity = $this->em->getRepository('App:Cron')->find(10);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$entity->setId(10);
|
||||
$entity->setCommand("app:CrousGo");
|
||||
$entity->setDescription("Récupératoin des commandes CROUS & GO");
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(60);
|
||||
$entity->setNextexecdate($entity->getSubmitdate());
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
|
||||
// Job Fermeture automatique des guichets
|
||||
// Toute les 1mn
|
||||
$entity = $this->em->getRepository('App:Cron')->find(20);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$entity->setId(20);
|
||||
$entity->setCommand("app:FermetureGuichet");
|
||||
$entity->setDescription("Fermeture automatique des guichets");
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(60);
|
||||
$entity->setNextexecdate($entity->getSubmitdate());
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
|
||||
// Job Récupératoin la table de référence des articles
|
||||
// Toute les 24h à 3h00
|
||||
$entity = $this->em->getRepository('App:Cron')->find(1000);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$nextdate=$entity->getSubmitdate();
|
||||
$nextdate->setTime(3,0);
|
||||
|
||||
$entity->setId(1000);
|
||||
$entity->setCommand("app:CodeArticle");
|
||||
$entity->setDescription("Récupératoin la table de référence des articles");
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(86400);
|
||||
$entity->setNextexecdate($nextdate);
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
|
||||
// Job reinit des piles à 0
|
||||
// Toute les 24h à 3h00
|
||||
$entity = $this->em->getRepository('App:Cron')->find(1010);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$nextdate=$entity->getSubmitdate();
|
||||
$nextdate->setTime(3,0);
|
||||
|
||||
$entity->setId(1010);
|
||||
$entity->setCommand("app:RazPile");
|
||||
$entity->setDescription("Remet les piles des services à 0");
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(86400);
|
||||
$entity->setNextexecdate($nextdate);
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
|
||||
// Job reinit des piles à 0
|
||||
// Toute les 24h à 3h00
|
||||
$entity = $this->em->getRepository('App:Cron')->find(1020);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$nextdate=$entity->getSubmitdate();
|
||||
$nextdate->setTime(3,0);
|
||||
|
||||
$entity->setId(1020);
|
||||
$entity->setCommand("app:RazCommande");
|
||||
$entity->setDescription("Cloture et Purge des Commandes");
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(86400);
|
||||
$entity->setNextexecdate($nextdate);
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
|
||||
// On flush
|
||||
$this->em->flush();
|
||||
*/
|
||||
}
|
||||
}
|
82
src/schedule-2.0/src/Command/SetPasswordCommand.php
Normal file
82
src/schedule-2.0/src/Command/SetPasswordCommand.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
||||
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
|
||||
|
||||
|
||||
use Cadoles\CoreBundle\Entity\User;
|
||||
|
||||
class SetPasswordCommand extends Command
|
||||
{
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
private $filesystem;
|
||||
private $rootlog;
|
||||
|
||||
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->container = $container;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('app:setPassword')
|
||||
->setDescription("Modifier le password d'un utilisateur")
|
||||
->setHelp("Modifier le password d'un utilisateur")
|
||||
->addArgument('username', InputArgument::OPTIONAL, 'username')
|
||||
->addArgument('password', InputArgument::OPTIONAL, 'password')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->rootlog = $this->container->get('kernel')->getProjectDir()."/../var/log/";
|
||||
|
||||
$this->writelnred('');
|
||||
$this->writelnred('== app:SetPasword');
|
||||
$this->writelnred('==========================================================================================================');
|
||||
|
||||
$username = $input->getArgument('username');
|
||||
$this->writeln($username);
|
||||
|
||||
$password = $input->getArgument('password');
|
||||
$this->writeln($password);
|
||||
|
||||
$user = $this->em->getRepository('App:User')->findOneBy(array('username' => $username));
|
||||
if($user) {
|
||||
// Set Password
|
||||
$user->setPassword($password);
|
||||
$this->em->persist($user);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
$this->writeln('');
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function writelnred($string) {
|
||||
$this->output->writeln('<fg=red>'.$string.'</>');
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
private function writeln($string) {
|
||||
$this->output->writeln($string);
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
83
src/schedule-2.0/src/Command/SetRolesCommand.php
Normal file
83
src/schedule-2.0/src/Command/SetRolesCommand.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
||||
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
|
||||
|
||||
|
||||
use Cadoles\CoreBundle\Entity\User;
|
||||
|
||||
class SetRolesCommand extends Command
|
||||
{
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
private $filesystem;
|
||||
private $rootlog;
|
||||
|
||||
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->container = $container;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('app:setRoles')
|
||||
->setDescription("Modifier le rôle d'un utilisateur")
|
||||
->setHelp("Modifier le rôle d'un utilisateur")
|
||||
->addArgument('username', InputArgument::OPTIONAL, 'username')
|
||||
->addArgument('roles', InputArgument::OPTIONAL, 'roles')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->rootlog = $this->container->get('kernel')->getProjectDir()."/../var/log/";
|
||||
|
||||
$this->writelnred('');
|
||||
$this->writelnred('== app:setRoles');
|
||||
$this->writelnred('==========================================================================================================');
|
||||
|
||||
$username = $input->getArgument('username');
|
||||
$this->writeln($username);
|
||||
|
||||
$this->writeln($input->getArgument('roles'));
|
||||
$roles = explode(",",$input->getArgument('roles'));
|
||||
//$this->writeln($roles);
|
||||
|
||||
$user = $this->em->getRepository('App:User')->findOneBy(array('username' => $username));
|
||||
if($user) {
|
||||
// Set Password
|
||||
$user->setRoles($roles);
|
||||
$this->em->persist($user);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
$this->writeln('');
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function writelnred($string) {
|
||||
$this->output->writeln('<fg=red>'.$string.'</>');
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
private function writeln($string) {
|
||||
$this->output->writeln($string);
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
0
src/schedule-2.0/src/Controller/.gitignore
vendored
Normal file
0
src/schedule-2.0/src/Controller/.gitignore
vendored
Normal file
163
src/schedule-2.0/src/Controller/BreakdayController.php
Executable file
163
src/schedule-2.0/src/Controller/BreakdayController.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Breakday as Entity;
|
||||
use App\Form\BreakdayType as Form;
|
||||
|
||||
class BreakdayController extends AbstractController
|
||||
{
|
||||
private $data = "breakday";
|
||||
private $route = "app_breakday";
|
||||
private $render = "Breakday/";
|
||||
private $entity = "App:Breakday";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'joursferiee.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$end = clone $data->getStart();
|
||||
$end->add(new \DateInterval('P1D'));
|
||||
$data->setEnd($end);
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$end = clone $data->getStart();
|
||||
$end->add(new \DateInterval('P1D'));
|
||||
$data->setEnd($end);
|
||||
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
138
src/schedule-2.0/src/Controller/CronController.php
Normal file
138
src/schedule-2.0/src/Controller/CronController.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use App\Entity\Cron as Entity;
|
||||
use App\Form\CronType as Form;
|
||||
|
||||
class CronController extends AbstractController
|
||||
{
|
||||
private $data = "cron";
|
||||
private $route = "app_cron";
|
||||
private $render = "Cron/";
|
||||
private $entity = "App:Cron";
|
||||
|
||||
public function list()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function execAction(Request $request, $id)
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$kernel = $this->get('kernel');
|
||||
$application = new Application($kernel);
|
||||
$application->setAutoExit(false);
|
||||
$command = $application->find($entity->getCommand());
|
||||
$jsonparameter=json_decode($entity->getJsonargument(),true);
|
||||
$parameter = ($jsonparameter?new ArrayInput($jsonparameter):new ArrayInput([]));
|
||||
|
||||
|
||||
$output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL,false);
|
||||
$command->run($parameter, $output);
|
||||
$content = $output->fetch();
|
||||
|
||||
return $this->render('CadolesCoreBundle:Core:command.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
"title" => $entity->getDescription(),
|
||||
"return_path" =>"cadoles_cron_config",
|
||||
"content" =>$content
|
||||
]);
|
||||
}
|
||||
|
||||
public function logAction(Request $request, $id)
|
||||
{
|
||||
$kernel = $this->get('kernel');
|
||||
$path = $this->get('kernel')->getRootDir() . '/../var/logs/'.$id.'.log';
|
||||
$content = file_get_contents($path);
|
||||
|
||||
return $this->render('CadolesCronBundle:Cron:logs.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
"title" => "LOG = ".$id,
|
||||
"content" => $content
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
167
src/schedule-2.0/src/Controller/CropController.php
Normal file
167
src/schedule-2.0/src/Controller/CropController.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
class CropController extends AbstractController
|
||||
{
|
||||
// Etape 01 - Téléchargement de l'image
|
||||
public function crop01()
|
||||
{
|
||||
return $this->render('Crop/crop01.html.twig',[
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
// Etape 02 - Couper votre l'image
|
||||
public function crop02(Request $request)
|
||||
{
|
||||
// Récupération de l'image à cropper
|
||||
$large_image_location = "uploads/avatar/".$this->get('session')->get('uploadavatar');
|
||||
|
||||
// Récupérer les tailles de l'image
|
||||
$width = $this->getWidth($large_image_location);
|
||||
$height = $this->getHeight($large_image_location);
|
||||
|
||||
// Définir le pourcentage de réduction de l'image
|
||||
$max_height=400000;
|
||||
$max_width=800;
|
||||
$scale = $max_height/$height;
|
||||
if(($width*$scale)>$max_width) {
|
||||
$scale = $max_width/$width;
|
||||
}
|
||||
$this->resizeImage($large_image_location,$width,$height,$scale);
|
||||
|
||||
// Construction du formulaire
|
||||
$form = $this->createFormBuilder()
|
||||
->add('submit',SubmitType::class,array("label" => "Valider","attr" => array("class" => "btn btn-success","onclick" => "reportThumb()")))
|
||||
->add('x',HiddenType::class)
|
||||
->add('y',HiddenType::class)
|
||||
->add('w',HiddenType::class)
|
||||
->add('h',HiddenType::class)
|
||||
->getForm();
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur validation on généère la miniature croppée
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
// Récupération des valeurs du formulaire
|
||||
$data = $form->getData();
|
||||
|
||||
$thumb_image_location = "uploads/avatar/thumb_".$this->get('session')->get('uploadavatar');;
|
||||
$cropped = $this->resizeThumbnailImage($thumb_image_location, $large_image_location,$data["w"],$data["h"],$data["x"],$data["y"],$scale);
|
||||
}
|
||||
|
||||
return $this->render('Crop/crop02.html.twig', [
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Calcul de la hauteur
|
||||
protected function getHeight($image) {
|
||||
$size = getimagesize($image);
|
||||
$height = $size[1];
|
||||
return $height;
|
||||
}
|
||||
|
||||
// Cacul de la largeur
|
||||
protected function getWidth($image) {
|
||||
dump($image);
|
||||
$size = getimagesize($image);
|
||||
$width = $size[0];
|
||||
return $width;
|
||||
}
|
||||
|
||||
protected function resizeImage($image,$width,$height,$scale) {
|
||||
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
|
||||
$imageType = image_type_to_mime_type($imageType);
|
||||
$newImageWidth = ceil($width * $scale);
|
||||
$newImageHeight = ceil($height * $scale);
|
||||
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
$source=imagecreatefromgif($image);
|
||||
break;
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
$source=imagecreatefromjpeg($image);
|
||||
break;
|
||||
case "image/png":
|
||||
case "image/x-png":
|
||||
$source=imagecreatefrompng($image);
|
||||
break;
|
||||
}
|
||||
imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
|
||||
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
imagegif($newImage,$image);
|
||||
break;
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
imagejpeg($newImage,$image,90);
|
||||
break;
|
||||
case "image/png":
|
||||
case "image/x-png":
|
||||
imagepng($newImage,$image);
|
||||
break;
|
||||
}
|
||||
|
||||
chmod($image, 0640);
|
||||
return $image;
|
||||
}
|
||||
|
||||
protected function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
|
||||
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
|
||||
$imageType = image_type_to_mime_type($imageType);
|
||||
|
||||
$newImageWidth = ceil($width * $scale);
|
||||
$newImageHeight = ceil($height * $scale);
|
||||
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
$source=imagecreatefromgif($image);
|
||||
break;
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
$source=imagecreatefromjpeg($image);
|
||||
break;
|
||||
case "image/png":
|
||||
case "image/x-png":
|
||||
$source=imagecreatefrompng($image);
|
||||
break;
|
||||
}
|
||||
imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
imagegif($newImage,$thumb_image_name);
|
||||
break;
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
imagejpeg($newImage,$thumb_image_name,90);
|
||||
break;
|
||||
case "image/png":
|
||||
case "image/x-png":
|
||||
imagepng($newImage,$thumb_image_name);
|
||||
break;
|
||||
}
|
||||
chmod($thumb_image_name, 0640);
|
||||
return $thumb_image_name;
|
||||
}
|
||||
|
||||
}
|
173
src/schedule-2.0/src/Controller/CustomerController.php
Executable file
173
src/schedule-2.0/src/Controller/CustomerController.php
Executable file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Customer as Entity;
|
||||
use App\Form\CustomerType as Form;
|
||||
|
||||
class CustomerController extends AbstractController
|
||||
{
|
||||
private $data = "customer";
|
||||
private $route = "app_customer";
|
||||
private $render = "Customer/";
|
||||
private $entity = "App:Customer";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'clients.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'client.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
465
src/schedule-2.0/src/Controller/EventController.php
Executable file
465
src/schedule-2.0/src/Controller/EventController.php
Executable file
@@ -0,0 +1,465 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
|
||||
use App\Entity\Event as Entity;
|
||||
use App\Form\EventType as Form;
|
||||
use App\Entity\Penalty;
|
||||
|
||||
class EventController extends AbstractController
|
||||
{
|
||||
private $data = "event";
|
||||
private $route = "app_event";
|
||||
private $render = "Event/";
|
||||
private $entity = "App:Event";
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$users = $em->getRepository("App:User")->findAll();
|
||||
$tasks = $em->getRepository("App:Task")->findAll();
|
||||
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"users" => $users,
|
||||
"tasks" => $tasks
|
||||
]);
|
||||
}
|
||||
|
||||
public function load(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$tbevents=[];
|
||||
|
||||
// Evenements
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
if($iduser=="all")
|
||||
$events=$em->getRepository("App:Event")->findAll();
|
||||
else {
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
$user=$em->getRepository("App:User")->find($iduser);
|
||||
$events=$em->getRepository("App:Event")->findBy(["user"=>$user]);
|
||||
}
|
||||
|
||||
foreach($events as $event) {
|
||||
$tmp=$this->formatEvent($event);
|
||||
array_push($tbevents,$tmp);
|
||||
}
|
||||
|
||||
// Astreintes
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
if($iduser=="all")
|
||||
$penaltys=$em->getRepository("App:Penalty")->findAll();
|
||||
else {
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
$user=$em->getRepository("App:User")->find($iduser);
|
||||
$penaltys=$em->getRepository("App:Penalty")->findBy(["user"=>$user]);
|
||||
}
|
||||
|
||||
foreach($penaltys as $penalty) {
|
||||
$tmp=$this->formatEvent($penalty);
|
||||
array_push($tbevents,$tmp);
|
||||
|
||||
}
|
||||
|
||||
// Breakday
|
||||
$breakdays=$em->getRepository("App:Breakday")->findAll();
|
||||
foreach($breakdays as $breakday) {
|
||||
$tmp=$this->formatBreakday($breakday);
|
||||
array_push($tbevents,$tmp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Retour
|
||||
return new Response(json_encode($tbevents));
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
// Récupération des variables envoyées en post
|
||||
$iduser = $request->request->get('iduser');
|
||||
$idtask = $request->request->get('idtask');
|
||||
$start = $request->request->get('start');
|
||||
$end = $request->request->get('end');
|
||||
$am = ($request->request->get('am')=="true");
|
||||
$ap = ($request->request->get('ap')=="true");
|
||||
$astreinte = ($request->request->get('astreinte')=="true");
|
||||
$description = $request->request->get('description');
|
||||
|
||||
$user = $em->getRepository("App:User")->find($iduser);
|
||||
$task = $em->getRepository("App:Task")->find($idtask);
|
||||
|
||||
// Controle de cohérance
|
||||
if(!$user) {
|
||||
$output=["return"=>"KO","error"=>"Utilisateur inconnu"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
if(!$task) {
|
||||
$output=["return"=>"KO","error"=>"Tâche inconnu"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// Convertir les dates string en date
|
||||
$datestart=new \DateTime($start);
|
||||
$dateend =new \DateTime($end);
|
||||
|
||||
if($am&&$ap) {
|
||||
$datestart->SetTime(0,0,0);
|
||||
$dateend->add(new \DateInterval('P1D'));
|
||||
$dateend->SetTime(0,0,0);
|
||||
$duration=$dateend->diff($datestart)->d;
|
||||
$allday=true;
|
||||
}
|
||||
else {
|
||||
$duration=0.5;
|
||||
$allday=false;
|
||||
if($am) {
|
||||
$datestart->SetTime(9,0,0);
|
||||
$dateend->SetTime(12,0,0);
|
||||
}
|
||||
else {
|
||||
$datestart->SetTime(13,0,0);
|
||||
$dateend->SetTime(17,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
// Astreinte
|
||||
if($astreinte) {
|
||||
// On regarde si une tache ne commence pas pendant une autre intervention ou qui se termine pendant une autre intervention ou qui a une intervention compris dans ses dates
|
||||
$penaltys = $em->createQueryBuilder('penalty')
|
||||
->select('penalty')
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('penalty.user=:user AND penalty.start<=:start AND penalty.end >:start')
|
||||
->orWhere('penalty.user=:user AND penalty.start<:end AND penalty.end >=:end')
|
||||
->orWhere('penalty.user=:user AND penalty.start>:start AND penalty.end <:end')
|
||||
->setParameter('user',$iduser)
|
||||
->setParameter('start',$datestart)
|
||||
->setParameter('end',$dateend)
|
||||
->getQuery()->getResult();
|
||||
if($penaltys) {
|
||||
$tbpenalty=[];
|
||||
foreach($penaltys as $penalty) {
|
||||
$tmp=[
|
||||
"id" => $penalty->getId(),
|
||||
"start" => $penalty->getStart(),
|
||||
"end" => $penalty->getEnd(),
|
||||
];
|
||||
array_push($tbpenalty,$tmp);
|
||||
}
|
||||
$output=["return"=>"KO","error"=>"Cet intervant a déjà une tache à cette date","start"=>$datestart,"end"=>$dateend,"events"=>$tbpenalty];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// Création de l'astreinte
|
||||
$penalty = new Penalty();
|
||||
$penalty->setStart($datestart);
|
||||
$penalty->setEnd($dateend);
|
||||
$penalty->setDuration($duration);
|
||||
$penalty->setAllday($allday);
|
||||
$penalty->setDescription($description);
|
||||
$penalty->setUser($user);
|
||||
$penalty->setTask($task);
|
||||
$penalty->setValidate(false);
|
||||
|
||||
$em->persist($penalty);
|
||||
$em->flush();
|
||||
|
||||
$output=$this->formatEvent($penalty);
|
||||
|
||||
}
|
||||
|
||||
// Evenement
|
||||
else {
|
||||
// On regarde si une tache ne commence pas pendant une autre intervention ou qui se termine pendant une autre intervention ou qui a une intervention compris dans ses dates
|
||||
$events = $em->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user AND event.start<=:start AND event.end >:start')
|
||||
->orWhere('event.user=:user AND event.start<:end AND event.end >=:end')
|
||||
->orWhere('event.user=:user AND event.start>:start AND event.end <:end')
|
||||
->setParameter('user',$iduser)
|
||||
->setParameter('start',$datestart)
|
||||
->setParameter('end',$dateend)
|
||||
->getQuery()->getResult();
|
||||
if($events) {
|
||||
$tbevent=[];
|
||||
foreach($events as $event) {
|
||||
$tmp=[
|
||||
"id" => $event->getId(),
|
||||
"start" => $event->getStart(),
|
||||
"end" => $event->getEnd(),
|
||||
];
|
||||
array_push($tbevent,$tmp);
|
||||
}
|
||||
$output=["return"=>"KO","error"=>"Cet intervant a déjà une tache à cette date","start"=>$datestart,"end"=>$dateend,"events"=>$tbevent];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// On regarde si un jour férié ne commence pas pendant une autre intervention ou qui se termine pendant une autre intervention ou qui a une intervention compris dans ses dates
|
||||
$breakdays = $em->createQueryBuilder('breakday')
|
||||
->select('breakday')
|
||||
->from('App:Breakday','breakday')
|
||||
->Where('breakday.start<=:start AND breakday.end >:start')
|
||||
->orWhere('breakday.start<:end AND breakday.end >=:end')
|
||||
->orWhere('breakday.start>:start AND breakday.end <:end')
|
||||
->setParameter('start',$datestart)
|
||||
->setParameter('end',$dateend)
|
||||
->getQuery()->getResult();
|
||||
if($breakdays) {
|
||||
$tbevent=[];
|
||||
foreach($breakdays as $breakday) {
|
||||
$tmp=[
|
||||
"id" => $breakday->getId(),
|
||||
"start" => $breakday->getStart(),
|
||||
"end" => $breakday->getEnd(),
|
||||
];
|
||||
array_push($tbevent,$tmp);
|
||||
}
|
||||
$output=["return"=>"KO","error"=>"Cet intervant a déjà une tache à cette date","start"=>$datestart,"end"=>$dateend,"events"=>$tbevent];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
|
||||
// Création de l'évenement
|
||||
$event = new Entity();
|
||||
$event->setStart($datestart);
|
||||
$event->setEnd($dateend);
|
||||
$event->setDuration($duration);
|
||||
$event->setAllday($allday);
|
||||
$event->setDescription($description);
|
||||
$event->setUser($user);
|
||||
$event->setTask($task);
|
||||
$event->setValidate(false);
|
||||
$event->setValidateholiday(false);
|
||||
|
||||
$em->persist($event);
|
||||
$em->flush();
|
||||
|
||||
$output=$this->formatEvent($event);
|
||||
}
|
||||
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
// Récupération des variables envoyées en post
|
||||
$idevent = str_replace("A","",$request->request->get('idevent'));
|
||||
$iduser = $request->request->get('iduser');
|
||||
$idtask = $request->request->get('idtask');
|
||||
$fgastreinte = ($request->request->get('fgastreinte')=="true");
|
||||
$description = $request->request->get('description');
|
||||
|
||||
$user = $em->getRepository("App:User")->find($iduser);
|
||||
$task = $em->getRepository("App:Task")->find($idtask);
|
||||
|
||||
// Controle de cohérance
|
||||
if(!$user) {
|
||||
$output=["return"=>"KO","error"=>"Utilisateur inconnu"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
if(!$task) {
|
||||
$output=["return"=>"KO","error"=>"Tâche inconnue"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// Astreinte
|
||||
if($fgastreinte) {
|
||||
// Recherche de l'event
|
||||
$penalty = $em->getRepository("App:Penalty")->find($idevent);
|
||||
if(!$penalty) {
|
||||
$output=["return"=>"KO","error"=>"L'évènement n'existe plus"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
if($penalty->getValidate()) {
|
||||
$output=["return"=>"KO","error"=>"Modification impossible l'évènement a été validé"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// Modification de l'évenement
|
||||
$penalty->setDescription($description);
|
||||
$penalty->setUser($user);
|
||||
$penalty->setTask($task);
|
||||
|
||||
$em->persist($penalty);
|
||||
$em->flush();
|
||||
|
||||
$output=$this->formatEvent($penalty);
|
||||
}
|
||||
|
||||
// Evenement
|
||||
else {
|
||||
// Recherche de l'event
|
||||
$event = $em->getRepository("App:Event")->find($idevent);
|
||||
if(!$event) {
|
||||
$output=["return"=>"KO","error"=>"L'évènement n'existe plus"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
if($event->getValidate()||$event->getValidateholiday()) {
|
||||
$output=["return"=>"KO","error"=>"Modification impossible l'évènement a été validé"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// Modification de l'évenement
|
||||
$event->setDescription($description);
|
||||
$event->setUser($user);
|
||||
$event->setTask($task);
|
||||
|
||||
$em->persist($event);
|
||||
$em->flush();
|
||||
|
||||
$output=$this->formatEvent($event);
|
||||
}
|
||||
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
// Récupération des variables envoyées en post
|
||||
$idevent = str_replace("A","",$request->request->get('idevent'));
|
||||
$fgastreinte = ($request->request->get('fgastreinte')=="true");
|
||||
|
||||
// Astreinte
|
||||
if($fgastreinte) {
|
||||
// Recherche de l'event
|
||||
$penalty = $em->getRepository("App:Penalty")->find($idevent);
|
||||
if(!$penalty) {
|
||||
$output=["return"=>"KO","error"=>"L'évènement n'existe plus"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
if($penalty->getValidate()) {
|
||||
$output=["return"=>"KO","error"=>"Modification impossible l'évènement a été validé"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// Suppression de l'évenement
|
||||
$em->remove($penalty);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
// Evenement
|
||||
else {
|
||||
// Recherche de l'event
|
||||
$event = $em->getRepository("App:Event")->find($idevent);
|
||||
if(!$event) {
|
||||
$output=["return"=>"KO","error"=>"L'évènement n'existe plus"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
if($event->getValidate()||$event->getValidateholiday()) {
|
||||
$output=["return"=>"KO","error"=>"Modification impossible l'évènement a été validé"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// Suppression de l'évenement
|
||||
$em->remove($event);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
$output=[];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function formatEvent($event) {
|
||||
$editable=(!($event->getValidate())&&!($event->getValidateholiday()));
|
||||
|
||||
// Si l'utilisateur en cours est différent de celui de l'event = seul MASTER - ADMIN peuvent modifier
|
||||
if($event->getUser()!=$this->getUser()) {
|
||||
if(!$this->isGranted('ROLE_ADMIN')&&!$this->isGranted('ROLE_MASTER'))
|
||||
$editable=false;
|
||||
}
|
||||
|
||||
|
||||
$tmp= [
|
||||
"id"=> ($event instanceof Penalty?"A":"").$event->getId(),
|
||||
"title" => ($event instanceof Penalty?"ASTREINTE = ":"").$event->getTask()->getDisplayname(),
|
||||
"start" => $event->getStart()->format("Y-m-d H:i"),
|
||||
"end" => $event->getEnd()->format("Y-m-d H:i"),
|
||||
"backgroundColor" => $event->getTask()->getColor(),
|
||||
"borderColor" => $event->getTask()->getColor(),
|
||||
"textColor" => "#ffffff",
|
||||
"allDay" => $event->getAllday(),
|
||||
"editable" => $editable,
|
||||
"durationEditable" => false,
|
||||
"extendedProps" => [
|
||||
"fulldescription" => ($event instanceof Penalty?"ASTREINTE\n":"").strtoupper($event->getTask()->getDisplayname())."\n\n".$event->getDescription(),
|
||||
"description" => $event->getDescription(),
|
||||
"userid" => $event->getUser()->getId(),
|
||||
"taskid" => $event->getTask()->getId(),
|
||||
"avatar" => "/".$this->getParameter("appAlias")."/uploads/avatar/".$event->getUser()->getAvatar(),
|
||||
"estimate" => $event->getTask()->getDuration($event->getEnd())." / ".$event->getTask()->getQuantity(),
|
||||
"locked" => $event->getValidate()||$event->getValidateholiday(),
|
||||
"editable" => $editable,
|
||||
"astreinte" => ($event instanceof Penalty)
|
||||
]
|
||||
];
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public function formatBreakday($event) {
|
||||
$editable=false;
|
||||
|
||||
$tmp= [
|
||||
"id"=> "B".$event->getId(),
|
||||
"title" => "Jour Férié",
|
||||
"start" => $event->getStart()->format("Y-m-d H:i"),
|
||||
"end" => $event->getEnd()->format("Y-m-d H:i"),
|
||||
"backgroundColor" => "#cdcdcd",
|
||||
"borderColor" => "#cdcdcd",
|
||||
"textColor" => "#ffffff",
|
||||
"allDay" => true,
|
||||
"editable" => false,
|
||||
"durationEditable" => false,
|
||||
"extendedProps" => [
|
||||
"fulldescription" => "Jour Férié",
|
||||
"description" => "Jour Férié",
|
||||
"userid" => null,
|
||||
"taskid" => null,
|
||||
"avatar" => "/".$this->getParameter("appAlias")."/uploads/avatar/".$this->getUser()->getAvatar(),
|
||||
"estimate" => "",
|
||||
"locked" => true,
|
||||
"editable" => false,
|
||||
"astreinte" => false
|
||||
]
|
||||
];
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
104
src/schedule-2.0/src/Controller/HomeController.php
Executable file
104
src/schedule-2.0/src/Controller/HomeController.php
Executable file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HomeController extends AbstractController
|
||||
{
|
||||
public function home()
|
||||
{
|
||||
return $this->redirectToRoute("app_synthese");
|
||||
|
||||
/*
|
||||
if($this->getUser()) {
|
||||
return $this->redirectToRoute("app_synthese");
|
||||
}
|
||||
else {
|
||||
return $this->render('Home/home.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => false,
|
||||
]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function selectmonth(Request $request)
|
||||
{
|
||||
$nbmonth = $request->request->get('nbmonth');
|
||||
$this->get('session')->set('nbmonth',$nbmonth);
|
||||
$output=["return"=>"OK"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function selectuser(Request $request)
|
||||
{
|
||||
$iduser = $request->request->get('iduser');
|
||||
$this->get('session')->set('iduser',$iduser);
|
||||
$output=["return"=>"OK"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function selectproject(Request $request)
|
||||
{
|
||||
$idproject = $request->request->get('idproject');
|
||||
$this->get('session')->set('idproject',$idproject);
|
||||
$output=["return"=>"OK"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function selectservice(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$idservice = $request->request->get('idservice');
|
||||
$this->get('session')->set('idservice',$idservice);
|
||||
$output=["return"=>"OK"];
|
||||
|
||||
// On recalcul les users
|
||||
if($idservice=="all")
|
||||
$users=$em->getRepository("App:User")->findAll();
|
||||
else
|
||||
$users=$em->getRepository("App:User")->findBy(["service"=>$idservice]);
|
||||
$tbusers=[];
|
||||
$haveuser=false;
|
||||
foreach($users as $user) {
|
||||
if(in_array("ROLE_USER",$user->getRoles())) {
|
||||
if($user->getId()==$this->get('session')->get('iduser'))
|
||||
$haveuser=true;
|
||||
|
||||
$tmp=[
|
||||
"id"=>$user->getId(),
|
||||
"displayname"=>$user->getDisplayname()
|
||||
];
|
||||
array_push($tbusers,$tmp);
|
||||
}
|
||||
}
|
||||
$this->get('session')->set('users',$tbusers);
|
||||
if(!$haveuser) $this->get('session')->set("iduser","all");
|
||||
|
||||
// On recalcul les projets
|
||||
if($idservice=="all")
|
||||
$projects=$em->getRepository('App:Project')->findBy(["active"=>$this->get('session')->get('activeproject')]);
|
||||
else
|
||||
$projects=$em->getRepository('App:Project')->findBy(["active"=>$this->get('session')->get('activeproject'),"service"=>$idservice]);
|
||||
$tbprojects=[];
|
||||
$haveproject=false;
|
||||
foreach($projects as $project) {
|
||||
if($project->getId()==$this->get('session')->get('idproject'))
|
||||
$haveproject=true;
|
||||
|
||||
$tmp=[
|
||||
"id"=>$project->getId(),
|
||||
"displayname"=>$project->getDisplayname()
|
||||
];
|
||||
array_push($tbprojects,$tmp);
|
||||
}
|
||||
$this->get('session')->set('projects',$tbprojects);
|
||||
if(!$haveproject) $this->get('session')->set("idproject","all");
|
||||
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
}
|
205
src/schedule-2.0/src/Controller/JobController.php
Executable file
205
src/schedule-2.0/src/Controller/JobController.php
Executable file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Job as Entity;
|
||||
use App\Form\JobType as Form;
|
||||
|
||||
class JobController extends AbstractController
|
||||
{
|
||||
private $data = "job";
|
||||
private $route = "app_job";
|
||||
private $render = "Job/";
|
||||
private $entity = "App:Job";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'fonctions.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'fonction.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
public function select(Request $request)
|
||||
{
|
||||
// S'assurer que c'est un appel ajax
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
return new JsonResponse(array('message' => 'Interdit'), 400);
|
||||
}
|
||||
|
||||
$output=array();
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$page_limit=$request->query->get('page_limit');
|
||||
$q=$request->query->get('q');
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('table')->from("App:Job",'table')
|
||||
->where('table.name LIKE :value')
|
||||
->andWhere('table.type != :type')
|
||||
->setParameter("value", "%".$q."%")
|
||||
->setParameter("type","Projet")
|
||||
->orderBy('table.type')
|
||||
->orderBy('table.name');
|
||||
|
||||
$datas=$qb->setFirstResult(0)->setMaxResults($page_limit)->getQuery()->getResult();
|
||||
foreach($datas as $data) {
|
||||
array_push($output,array("id"=>$data->getId(),"text"=>$data->getType()." - ".$data->getName()));
|
||||
}
|
||||
|
||||
$ret_string["results"]=$output;
|
||||
$response = new Response(json_encode($ret_string));
|
||||
$response->headers->set('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
156
src/schedule-2.0/src/Controller/NatureController.php
Executable file
156
src/schedule-2.0/src/Controller/NatureController.php
Executable file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Nature as Entity;
|
||||
use App\Form\NatureType as Form;
|
||||
|
||||
class NatureController extends AbstractController
|
||||
{
|
||||
private $data = "nature";
|
||||
private $route = "app_nature";
|
||||
private $render = "Nature/";
|
||||
private $entity = "App:Nature";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'natures.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
184
src/schedule-2.0/src/Controller/OfferController.php
Executable file
184
src/schedule-2.0/src/Controller/OfferController.php
Executable file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Offer as Entity;
|
||||
use App\Form\OfferType as Form;
|
||||
|
||||
class OfferController extends AbstractController
|
||||
{
|
||||
private $data = "offer";
|
||||
private $route = "app_offer";
|
||||
private $render = "Offer/";
|
||||
private $entity = "App:Offer";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$services=$em->getRepository("App:Service")->findAllOfferActive($this->get('session')->get('activeproject'),$this->get('session')->get('activeoffer'),$this->get('session')->get('idservice'));
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
"services" => $services,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]),
|
||||
'propositions.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
"services" => $services,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'proposition.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
public function activeproject() {
|
||||
$this->get('session')->set('activeproject',!$this->get('session')->get('activeproject'));
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
public function activeoffer() {
|
||||
$this->get('session')->set('activeoffer',!$this->get('session')->get('activeoffer'));
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
321
src/schedule-2.0/src/Controller/ProjectController.php
Executable file
321
src/schedule-2.0/src/Controller/ProjectController.php
Executable file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Project as Entity;
|
||||
use App\Form\ProjectType as Form;
|
||||
use App\Entity\Userproject as Userproject;
|
||||
|
||||
class ProjectController extends AbstractController
|
||||
{
|
||||
private $data = "project";
|
||||
private $route = "app_project";
|
||||
private $render = "Project/";
|
||||
private $entity = "App:Project";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$services=$em->getRepository("App:Service")->findAllProjectActive($this->get('session')->get('activeproject'),$this->get('session')->get('idservice'));
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
"services" => $services,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]),
|
||||
'projets.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
"services" => $services,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route."_users",["id"=>$data->getId()]);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'projet.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
public function select(Request $request) {
|
||||
// S'assurer que c'est un appel ajax
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
//return new JsonResponse(array('message' => 'Interdit'), 400);
|
||||
}
|
||||
|
||||
$output=array();
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$page_limit=$request->query->get('page_limit');
|
||||
$q=$request->query->get('q');
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select("project")
|
||||
->from("App:Project","project")
|
||||
->from("App:Customer", "customer")
|
||||
->where("project.name LIKE :value")
|
||||
->andWhere("project.customer=customer")
|
||||
->andWhere("customer.name LIKE :value")
|
||||
->setParameter("value", "%".$q."%")
|
||||
->orderBy('customer.name');
|
||||
|
||||
$datas=$qb->setFirstResult(0)->setMaxResults($page_limit)->getQuery()->getResult();
|
||||
foreach($datas as $data) {
|
||||
array_push($output,array("id"=>$data->getId(),"text"=>$data->getDisplayname()));
|
||||
}
|
||||
$output["results"]=$output;
|
||||
|
||||
$response = new Response(json_encode($output));
|
||||
$response->headers->set('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function users($id, Request $request) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant affichage
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$jobs=$em->getRepository("App:Job")->findBy(["type"=>"Projet"]);
|
||||
$users=$em->getRepository("App:User")->findAll();
|
||||
$userprojects=[];
|
||||
foreach($jobs as $job) {
|
||||
$entitys=$em->getRepository("App:Userproject")->findBy(["project"=>$data,"job"=>$job]);
|
||||
|
||||
if($entitys) $userprojects[$job->getId()]= [
|
||||
"id"=>$job->getId(),
|
||||
"name"=>$job->getName(),
|
||||
"users"=>$entitys
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render($this->render.'users.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'jobs' => $jobs,
|
||||
'users' => $users,
|
||||
'userprojects' => $userprojects
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function usersadd(Request $request) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$idproject = $request->request->get('idproject');
|
||||
$iduser = $request->request->get('iduser');
|
||||
$idjob = $request->request->get('idjob');
|
||||
|
||||
$project=$em->getRepository("App:Project")->find($idproject);
|
||||
$user=$em->getRepository("App:User")->find($iduser);
|
||||
$job=$em->getRepository("App:Job")->find($idjob);
|
||||
|
||||
if(!$project||!$user||!$job) {
|
||||
$output=["return"=>"KO","error"=>"Un élément a été supprimé entre temps "];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
$userproject = $em->getRepository("App:Userproject")->findBy(["user"=>$user,"project"=>$project,"job"=>$job]);
|
||||
if($userproject) {
|
||||
$output=["return"=>"KO","error"=>"Cet utilisateur a déjà ce metier sur ce projet"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
$userproject= new Userproject();
|
||||
$userproject->setUser($user);
|
||||
$userproject->setJob($job);
|
||||
$userproject->setProject($project);
|
||||
$em->persist($userproject);
|
||||
$em->flush();
|
||||
|
||||
return new Response(json_encode([]));
|
||||
|
||||
}
|
||||
|
||||
public function usersdel(Request $request) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$iduser = $request->request->get('iduser');
|
||||
$userproject = $em->getRepository("App:Userproject")->find($iduser);
|
||||
if($userproject) {
|
||||
$em->remove($userproject);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
}
|
||||
|
||||
return new Response(json_encode([]));
|
||||
|
||||
}
|
||||
|
||||
public function activeproject() {
|
||||
$this->get('session')->set('activeproject',!$this->get('session')->get('activeproject'));
|
||||
$this->refreshsession();
|
||||
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
protected function refreshsession() {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$tbprojects=[];
|
||||
$haveproject=false;
|
||||
|
||||
$projects=$em->getRepository('App:Project')->findBy(["active"=>$this->get('session')->get('activeproject')]);
|
||||
foreach($projects as $project) {
|
||||
if($project->getId()==$this->get('session')->get('idproject'))
|
||||
$haveproject=true;
|
||||
|
||||
$tmp=[
|
||||
"id"=>$project->getId(),
|
||||
"displayname"=>$project->getDisplayname()
|
||||
];
|
||||
|
||||
array_push($tbprojects,$tmp);
|
||||
}
|
||||
|
||||
if(!$haveproject) $this->get('session')->set("idproject","all");
|
||||
|
||||
$this->get('session')->set('projects',$tbprojects);
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
990
src/schedule-2.0/src/Controller/ReportController.php
Executable file
990
src/schedule-2.0/src/Controller/ReportController.php
Executable file
@@ -0,0 +1,990 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
class ReportController extends AbstractController
|
||||
{
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function synthese(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$nbmonth=$this->get("session")->get("nbmonth");
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
|
||||
if($iduser=="all") {
|
||||
$users=$em->getRepository("App:User")->findAll();
|
||||
}
|
||||
else {
|
||||
$users=$em->getRepository("App:User")->findBy(["id"=>$iduser]);
|
||||
}
|
||||
|
||||
$tbevents=[];
|
||||
foreach($users as $user) {
|
||||
if(in_array("ROLE_USER",$user->getRoles())) {
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($user->getService()->getId()!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmp=[
|
||||
"id" => $user->getId(),
|
||||
"user" => $user,
|
||||
"events" => [],
|
||||
];
|
||||
|
||||
// On formate le tableau de jour
|
||||
$start=new \Datetime('first day of this month');
|
||||
$start->modify('last Monday');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->modify('first Monday');
|
||||
while($start<$end) {
|
||||
$idday=$start->format("Ymd");
|
||||
$idmonth=$start->format("Ym");
|
||||
|
||||
$tmp["events"][$idday] = [
|
||||
"date"=>clone $start,
|
||||
"allday"=>false,
|
||||
"colorday"=>"",
|
||||
"descriptionday"=>"",
|
||||
"am"=>false,
|
||||
"coloram"=>"",
|
||||
"descriptionam"=>"",
|
||||
"ap"=>false,
|
||||
"colorap"=>"",
|
||||
"descriptionap"=>"",
|
||||
"astreinte"=>false,
|
||||
"colorastreinte"=>"",
|
||||
"descriptionastreinte"=>"",
|
||||
];
|
||||
|
||||
$start->add(new \DateInterval('P1D'));
|
||||
}
|
||||
|
||||
// On formate le tableau des event
|
||||
$start=new \Datetime('first day of this month');
|
||||
$start->modify('last Monday');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->modify('first Monday');
|
||||
|
||||
$events = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user AND event.start>=:start AND event.end <:end')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($events as $event) {
|
||||
$idproject=$event->getTask()->getProject()->getId();
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($idproject!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
$st=clone $event->getStart();
|
||||
while($st<$event->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
if($event->getAllday()) {
|
||||
$tmp["events"][$idday]["allday"]=true;
|
||||
$tmp["events"][$idday]["colorday"]=$event->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionday"]=strtoupper($event->getTask()->getDisplayname())."\n\n".$event->getDescription();
|
||||
}
|
||||
else {
|
||||
// Matin ou après-midi ?
|
||||
$time=$event->getStart()->format("H");
|
||||
if($time==9) {
|
||||
$tmp["events"][$idday]["am"]=true;
|
||||
$tmp["events"][$idday]["coloram"]=$event->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionam"]=strtoupper($event->getTask()->getDisplayname())."\n\n".$event->getDescription();
|
||||
}
|
||||
else {
|
||||
$tmp["events"][$idday]["ap"]=true;
|
||||
$tmp["events"][$idday]["colorap"]=$event->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionap"]=strtoupper($event->getTask()->getDisplayname())."\n\n".$event->getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
// On formate le tableau des astreintes
|
||||
$start=new \Datetime('first day of this month');
|
||||
$start->modify('last Monday');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->modify('first Monday');
|
||||
|
||||
$penaltys = $em
|
||||
->createQueryBuilder('penalty')
|
||||
->select('penalty')
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('penalty.user=:user AND penalty.start>=:start AND penalty.end <:end')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($penaltys as $penalty) {
|
||||
$idproject=$penalty->getTask()->getProject()->getId();
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($idproject!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
$st=clone $penalty->getStart();
|
||||
while($st<$penalty->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
if($penalty->getAllday()) {
|
||||
$tmp["events"][$idday]["astreinte"]=true;
|
||||
$tmp["events"][$idday]["colorastreinte"]=$penalty->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionastreinte"]=strtoupper($penalty->getTask()->getDisplayname())."\n\n".$penalty->getDescription();
|
||||
}
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
// On formate le tableau des jours fériés
|
||||
$start=new \Datetime('first day of this month');
|
||||
$start->modify('last Monday');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->modify('first Monday');
|
||||
|
||||
$breakdays = $em
|
||||
->createQueryBuilder('breakday')
|
||||
->select('breakday')
|
||||
->from('App:Breakday','breakday')
|
||||
->Where('breakday.start>=:start AND breakday.end <:end')
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($breakdays as $breakday) {
|
||||
$st=clone $breakday->getStart();
|
||||
while($st<$breakday->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
$tmp["events"][$idday]["allday"]=true;
|
||||
$tmp["events"][$idday]["colorday"]="#6c7a89";
|
||||
$tmp["events"][$idday]["descriptionday"]="Jour Férié";
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
array_push($tbevents,$tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView('Report/synthese.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'synthese.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render('Report/synthese.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
function planning($key=null,$access=null,Request $request) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
$nbmonth=$this->get("session")->get("nbmonth");
|
||||
|
||||
if($iduser=="all") {
|
||||
$users=$em->getRepository("App:User")->findAll();
|
||||
}
|
||||
else {
|
||||
$users=$em->getRepository("App:User")->findBy(["id"=>$iduser]);
|
||||
}
|
||||
|
||||
$projects=$em->getRepository("App:Project")->findAll();
|
||||
$tbprojects=[];
|
||||
foreach($projects as $project) {
|
||||
// Filtre par Customer
|
||||
if($access=="customer") {
|
||||
if($project->getCustomer()->getKeypass()!=$key)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($project->getService()->getId()!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($project->getId()!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ne prendre que les projets actif/inactif
|
||||
if($this->get('session')->get('activeproject')!=$project->getActive())
|
||||
continue;
|
||||
|
||||
// Ne pas prendre les projects sans event dans la durée
|
||||
$start=new \Datetime('first day of this month');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->sub(new \DateInterval('P1D'));
|
||||
$events = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Task','task')
|
||||
->from('App:Event','event')
|
||||
->Where('task.project=:project')
|
||||
->andWhere('event.task=task')
|
||||
->andWhere('event.start>=:start')
|
||||
->andWhere('event.end <:end')
|
||||
->setParameter('project',$project)
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
if(!$events)
|
||||
continue;
|
||||
|
||||
$validate=$em->getRepository("App:Project")->sumDuration($project->getId(),true);
|
||||
$planified=$em->getRepository("App:Project")->sumDuration($project->getId(),false);
|
||||
$estimate=$em->getRepository("App:Project")->sumEstimate($project->getId());
|
||||
$proposed=$em->getRepository("App:Project")->sumProposed($project->getId());
|
||||
|
||||
$tbproject = [
|
||||
"id"=>$project->getId(),
|
||||
"displayname"=>$project->getDisplayname(),
|
||||
"validate"=>$validate,
|
||||
"planified"=>$planified,
|
||||
"estimate"=>$estimate,
|
||||
"proposed"=>$proposed,
|
||||
"months"=>[],
|
||||
];
|
||||
|
||||
// Formater les mois
|
||||
$start=new \Datetime('first day of this month');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->sub(new \DateInterval('P1D'));
|
||||
while($start<$end) {
|
||||
$tbproject["months"][$start->format("Ym")]=[
|
||||
"monthid"=> $start->format("Ym"),
|
||||
"monthlabel"=>$start->format("m/Y"),
|
||||
"days"=>[],
|
||||
"users"=>[]
|
||||
];
|
||||
|
||||
// Init du tableau des utilisateurs pour le mois
|
||||
foreach($users as $user) {
|
||||
$tbuser= [
|
||||
"id"=>$user->getId(),
|
||||
"displayname"=>$user->getDisplayname(),
|
||||
"days"=>[]
|
||||
];
|
||||
$tbproject["months"][$start->format("Ym")]["users"][$user->getId()]=$tbuser;
|
||||
}
|
||||
|
||||
$start->add(new \DateInterval('P1M'));
|
||||
}
|
||||
|
||||
// Formater les jours
|
||||
$start=new \Datetime('first day of this month');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->sub(new \DateInterval('P1D'));
|
||||
|
||||
while($start<$end) {
|
||||
$tbday=[
|
||||
"date"=>clone $start,
|
||||
"daylabel"=>$this->frmDay($start->format("w")),
|
||||
"daycolor"=>$this->frmColorday($start->format("w")),
|
||||
"daynumber"=>$start->format("d"),
|
||||
];
|
||||
|
||||
$tbproject["months"][$start->format("Ym")]["days"][$start->format("Ymd")]=$tbday;
|
||||
|
||||
foreach($users as $user) {
|
||||
$tbday=[
|
||||
"date"=>clone $start,
|
||||
"duration"=>0,
|
||||
"astreinte"=>0,
|
||||
"daycolor"=>$this->frmColorday($start->format("w")),
|
||||
];
|
||||
|
||||
$tbproject["months"][$start->format("Ym")]["users"][$user->getId()]["days"][$start->format("Ymd")]=$tbday;
|
||||
}
|
||||
|
||||
$start->add(new \DateInterval('P1D'));
|
||||
}
|
||||
$tbprojects[$project->getId()]=$tbproject;
|
||||
}
|
||||
|
||||
// Formater les utilisateurs
|
||||
$start=new \Datetime('first day of this month');
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->sub(new \DateInterval('P1D'));
|
||||
|
||||
foreach($users as $user) {
|
||||
$tbevents = $this->getEventuser($user,$start,$end,false);
|
||||
|
||||
foreach($tbevents as $project) {
|
||||
foreach($project as $event) {
|
||||
if(isset($tbprojects[$event["idproject"]])) {
|
||||
$tbprojects[$event["idproject"]]["months"][$event["idmonth"]]["users"][$user->getId()]["days"][$event["idday"]]=
|
||||
[
|
||||
"date"=>$event["idday"],
|
||||
"duration"=>$event["duration"],
|
||||
"astreinte"=>$event["astreinte"],
|
||||
"daycolor"=>$event["daycolor"],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cumule
|
||||
foreach($tbprojects as $project) {
|
||||
foreach($project["months"] as $month) {
|
||||
$haveuser=false;
|
||||
$totmonth=0;
|
||||
$totmontha=0;
|
||||
|
||||
foreach($month["users"] as $user) {
|
||||
$totuser=0;
|
||||
$totusera=0;
|
||||
|
||||
foreach($user["days"] as $day) {
|
||||
$totuser+=$day["duration"];
|
||||
$totusera+=$day["astreinte"];
|
||||
|
||||
$totmonth+=$day["duration"];
|
||||
$totmontha+=$day["astreinte"];
|
||||
}
|
||||
|
||||
if($totuser==0&&$totusera==0) {
|
||||
unset($tbprojects[$project["id"]]["months"][$month["monthid"]]["users"][$user["id"]]);
|
||||
} else {
|
||||
$tbprojects[$project["id"]]["months"][$month["monthid"]]["users"][$user["id"]]["total"]=$totuser+$totusera;
|
||||
$haveuser=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$haveuser)
|
||||
unset($tbprojects[$project["id"]]["months"][$month["monthid"]]);
|
||||
else {
|
||||
$tbprojects[$project["id"]]["months"][$month["monthid"]]["total"]=$totmonth;
|
||||
$tbprojects[$project["id"]]["months"][$month["monthid"]]["totala"]=$totmontha;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView('Report/planning.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"projects" => $tbprojects,
|
||||
"access" => $access,
|
||||
"key" => $key,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]),
|
||||
'planning.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render('Report/planning.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"projects" => $tbprojects,
|
||||
"access" => $access,
|
||||
"key" => $key
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function report($key=null,$access=null,Request $request) {
|
||||
ini_set('memory_limit','500M');
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
$nbmonth=$this->get("session")->get("nbmonth");
|
||||
|
||||
if($iduser=="all") {
|
||||
$users=$em->getRepository("App:User")->findAll();
|
||||
}
|
||||
else {
|
||||
$users=$em->getRepository("App:User")->findBy(["id"=>$iduser]);
|
||||
}
|
||||
|
||||
$projects=$em->getRepository("App:Project")->findAll();
|
||||
|
||||
//Construction du tableau des projets
|
||||
$tbprojects=[];
|
||||
foreach($projects as $project) {
|
||||
// Filtre par Customer
|
||||
if($access=="customer") {
|
||||
if($project->getCustomer()->getKeypass()!=$key)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($project->getService()->getId()!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($project->getId()!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ne prendre que les projets actif/inactif
|
||||
if($this->get('session')->get('activeproject')!=$project->getActive())
|
||||
continue;
|
||||
|
||||
$validate=$em->getRepository("App:Project")->sumDuration($project->getId(),true);
|
||||
$planified=$em->getRepository("App:Project")->sumDuration($project->getId(),false);
|
||||
$estimate=$em->getRepository("App:Project")->sumEstimate($project->getId());
|
||||
$proposed=$em->getRepository("App:Project")->sumProposed($project->getId());
|
||||
|
||||
// Ne prendre que les projects avec du validé
|
||||
if($validate==0) continue;
|
||||
|
||||
// Somme des taches validé avant
|
||||
$event = $em
|
||||
->createQueryBuilder('task')
|
||||
->select('SUM(task.validate) as somme')
|
||||
->from('App:Task','task')
|
||||
->Where('task.project=:project')
|
||||
->setParameter('project',$project)
|
||||
->getQuery()->getOneOrNullResult();
|
||||
$hors1=($event["somme"]?$event["somme"]:0);
|
||||
$event = $em
|
||||
->createQueryBuilder('offer')
|
||||
->select('SUM(offer.validate) as somme')
|
||||
->from('App:Offer','offer')
|
||||
->Where('offer.project=:project')
|
||||
->setParameter('project',$project)
|
||||
->getQuery()->getOneOrNullResult();
|
||||
$hors2=($event["somme"]?$event["somme"]:0);
|
||||
$hors=$hors1+$hors2;
|
||||
|
||||
// Init tableau project
|
||||
$tbproject = [
|
||||
"id"=>$project->getId(),
|
||||
"displayname"=>$project->getDisplayname(),
|
||||
"validate"=>$validate,
|
||||
"planified"=>$planified,
|
||||
"estimate"=>$estimate,
|
||||
"proposed"=>$proposed,
|
||||
"hors"=>$hors,
|
||||
"before"=>[],
|
||||
"beforeastreinte"=>[],
|
||||
"months"=>[],
|
||||
"offers"=>[],
|
||||
];
|
||||
|
||||
// Somme event validé avant la date
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->sub(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$events = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Task','task')
|
||||
->from('App:Event','event')
|
||||
->Where('task.project=:project')
|
||||
->andWhere('event.task=task')
|
||||
->andWhere('event.end <:end')
|
||||
->andWhere('event.validate=:validate')
|
||||
->setParameter('project',$project)
|
||||
->setParameter('validate',true)
|
||||
->setParameter('end',$end)
|
||||
->orderBy('event.start')
|
||||
->getQuery()->getResult();
|
||||
foreach($events as $event) {
|
||||
if(!isset($tbproject["before"][$event->getStart()->format("Ym")])) {
|
||||
$tbproject["before"][$event->getStart()->format("Ym")] = [
|
||||
"idmonth" => $event->getStart()->format("Ym"),
|
||||
"monthlabel"=>$event->getStart()->format("m/Y"),
|
||||
"duration" => 0,
|
||||
];
|
||||
}
|
||||
$tbproject["before"][$event->getStart()->format("Ym")]["duration"]=$tbproject["before"][$event->getStart()->format("Ym")]["duration"]+$event->getDuration();
|
||||
}
|
||||
|
||||
// Somme astreinte validé avant la date
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->sub(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$penaltys = $em
|
||||
->createQueryBuilder('penalty')
|
||||
->select('penalty')
|
||||
->from('App:Task','task')
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('task.project=:project')
|
||||
->andWhere('penalty.task=task')
|
||||
->andWhere('penalty.end <:end')
|
||||
->andWhere('penalty.validate=:validate')
|
||||
->setParameter('project',$project)
|
||||
->setParameter('validate',true)
|
||||
->setParameter('end',$end)
|
||||
->orderBy('penalty.start')
|
||||
->getQuery()->getResult();
|
||||
foreach($penaltys as $penalty) {
|
||||
if(!isset($tbproject["beforeastreinte"][$penalty->getStart()->format("Ym")])) {
|
||||
$tbproject["beforeastreinte"][$penalty->getStart()->format("Ym")] = [
|
||||
"idmonth" => $penalty->getStart()->format("Ym"),
|
||||
"monthlabel"=>$penalty->getStart()->format("m/Y"),
|
||||
"duration" => 0,
|
||||
];
|
||||
}
|
||||
$tbproject["beforeastreinte"][$penalty->getStart()->format("Ym")]["duration"]=$tbproject["beforeastreinte"][$penalty->getStart()->format("Ym")]["duration"]+$penalty->getDuration();
|
||||
}
|
||||
|
||||
// Recap des propositions
|
||||
$offers=$em->getRepository("App:Offer")->findBy(["project"=>$project->getId()]);
|
||||
foreach($offers as $offer) {
|
||||
$tbproject["offers"][$offer->getId()] = [
|
||||
"name"=>$offer->getName(),
|
||||
"ref"=>$offer->getRef(),
|
||||
"quantity"=>$offer->getQuantity(),
|
||||
];
|
||||
}
|
||||
|
||||
// Formater les mois
|
||||
$start=new \Datetime('first day of this month');
|
||||
$start->sub(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->sub(new \DateInterval('P1D'));
|
||||
while($start<$end) {
|
||||
$tbproject["months"][$start->format("Ym")]=[
|
||||
"monthid"=> $start->format("Ym"),
|
||||
"monthlabel"=>$start->format("m/Y"),
|
||||
"days"=>[],
|
||||
"users"=>[],
|
||||
"tasks"=>[],
|
||||
];
|
||||
|
||||
// Init du tableau des utilisateurs pour le mois
|
||||
foreach($users as $user) {
|
||||
$tbuser= [
|
||||
"id"=>$user->getId(),
|
||||
"displayname"=>$user->getDisplayname(),
|
||||
"days"=>[]
|
||||
];
|
||||
$tbproject["months"][$start->format("Ym")]["users"][$user->getId()]=$tbuser;
|
||||
}
|
||||
|
||||
// Init des taches par mois
|
||||
$endmonth=clone $start;
|
||||
$endmonth->add(new \DateInterval('P1M'));
|
||||
|
||||
$events = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('task.id, task.name, SUM(event.duration) as somme')
|
||||
->from('App:Task','task')
|
||||
->from('App:Event','event')
|
||||
->Where('task.project=:project')
|
||||
->andWhere('event.task=task')
|
||||
->andWhere('event.end >=:start')
|
||||
->andWhere('event.end <:end')
|
||||
->andWhere('event.validate=:validate')
|
||||
->setParameter('project',$project)
|
||||
->setParameter('validate',true)
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$endmonth)
|
||||
->groupBy('task.id')
|
||||
->getQuery()->getResult();
|
||||
foreach($events as $event) {
|
||||
$tbtask= [
|
||||
"id"=>$event["id"],
|
||||
"displayname"=>$event["name"],
|
||||
"duration"=>$event["somme"]
|
||||
];
|
||||
$tbproject["months"][$start->format("Ym")]["tasks"][$event["id"]]=$tbtask;
|
||||
}
|
||||
|
||||
$start->add(new \DateInterval('P1M'));
|
||||
}
|
||||
|
||||
// Formater les jours
|
||||
$start=new \Datetime('first day of this month');
|
||||
$start->sub(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->sub(new \DateInterval('P1D'));
|
||||
|
||||
while($start<$end) {
|
||||
$tbday=[
|
||||
"date"=>clone $start,
|
||||
"daylabel"=>$this->frmDay($start->format("w")),
|
||||
"daycolor"=>$this->frmColorday($start->format("w")),
|
||||
"daynumber"=>$start->format("d"),
|
||||
];
|
||||
|
||||
$tbproject["months"][$start->format("Ym")]["days"][$start->format("Ymd")]=$tbday;
|
||||
|
||||
foreach($users as $user) {
|
||||
$tbday=[
|
||||
"date"=>clone $start,
|
||||
"duration"=>0,
|
||||
"astreinte"=>0,
|
||||
"daycolor"=>$this->frmColorday($start->format("w")),
|
||||
];
|
||||
|
||||
$tbproject["months"][$start->format("Ym")]["users"][$user->getId()]["days"][$start->format("Ymd")]=$tbday;
|
||||
}
|
||||
|
||||
$start->add(new \DateInterval('P1D'));
|
||||
}
|
||||
$tbprojects[$project->getId()]=$tbproject;
|
||||
}
|
||||
|
||||
// Formater les utilisateurs
|
||||
$start=new \Datetime('first day of this month');
|
||||
$start->sub(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end=new \Datetime('first day of this month');
|
||||
$end->add(new \DateInterval('P'.$nbmonth.'M'));
|
||||
$end->sub(new \DateInterval('P1D'));
|
||||
|
||||
foreach($users as $user) {
|
||||
$tbevents = $this->getEventuser($user,$start,$end,true);
|
||||
|
||||
foreach($tbevents as $project) {
|
||||
foreach($project as $event) {
|
||||
if(isset($tbprojects[$event["idproject"]])) {
|
||||
$tbprojects[$event["idproject"]]["months"][$event["idmonth"]]["users"][$user->getId()]["days"][$event["idday"]]=
|
||||
[
|
||||
"date"=>$event["idday"],
|
||||
"duration"=>$event["duration"],
|
||||
"astreinte"=>$event["astreinte"],
|
||||
"daycolor"=>$event["daycolor"],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cumule
|
||||
foreach($tbprojects as $project) {
|
||||
foreach($project["months"] as $month) {
|
||||
$haveuser=false;
|
||||
$totmonth=0;
|
||||
$totmontha=0;
|
||||
|
||||
foreach($month["users"] as $user) {
|
||||
$totuser=0;
|
||||
$totusera=0;
|
||||
|
||||
foreach($user["days"] as $day) {
|
||||
$totuser+=$day["duration"];
|
||||
$totusera+=$day["astreinte"];
|
||||
|
||||
$totmonth+=$day["duration"];
|
||||
$totmontha+=$day["astreinte"];
|
||||
}
|
||||
|
||||
if($totuser==0&&$totusera==0) {
|
||||
unset($tbprojects[$project["id"]]["months"][$month["monthid"]]["users"][$user["id"]]);
|
||||
} else {
|
||||
$tbprojects[$project["id"]]["months"][$month["monthid"]]["users"][$user["id"]]["total"]=$totuser+$totusera;
|
||||
$haveuser=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$haveuser)
|
||||
unset($tbprojects[$project["id"]]["months"][$month["monthid"]]);
|
||||
else {
|
||||
$tbprojects[$project["id"]]["months"][$month["monthid"]]["total"]=$totmonth;
|
||||
$tbprojects[$project["id"]]["months"][$month["monthid"]]["totala"]=$totmontha;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView('Report/report.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"projects" => $tbprojects,
|
||||
"access" => $access,
|
||||
"key" => $key,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]),
|
||||
'report.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render('Report/report.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"projects" => $tbprojects,
|
||||
"access" => $access,
|
||||
"key" => $key
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getEventuser($user,$start,$end,$onlyvalidate) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$tbevents=[];
|
||||
|
||||
// Récupération de event
|
||||
$qb = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user AND event.start>=:start AND event.end <:end')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end);
|
||||
if($onlyvalidate)
|
||||
$qb->andWhere('event.validate=:validate')->setParameter('validate',true);
|
||||
|
||||
$events=$qb->getQuery()->getResult();
|
||||
foreach($events as $event) {
|
||||
$project=$event->getTask()->getProject();
|
||||
$idproject=$project->getId();
|
||||
$idservice=$project->getService()->getId();
|
||||
$activeproject=$project->getActive();
|
||||
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($idservice!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($idproject!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ne prendre que les projets actif/inactif
|
||||
if($this->get('session')->get('activeproject')!=$activeproject)
|
||||
continue;
|
||||
|
||||
if(!isset($tbevents[$idproject]))
|
||||
$tbevents[$idproject] = [];
|
||||
|
||||
$st=clone $event->getStart();
|
||||
while($st<$event->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
$idmonth=$st->format("Ym");
|
||||
|
||||
if(!isset($tbevents[$idproject][$idday])) {
|
||||
$tbevents[$idproject][$idday] = [
|
||||
"idproject"=>$idproject,
|
||||
"idmonth"=>$idmonth,
|
||||
"idday"=>$idday,
|
||||
"daycolor"=>$this->frmColorday($st->format("w")),
|
||||
"duration"=>0,
|
||||
"astreinte"=>0,
|
||||
];
|
||||
}
|
||||
|
||||
$tbevents[$idproject][$idday]["duration"]=($event->getAllday()?1:0.5);
|
||||
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Récupération des astreintes
|
||||
$qb = $em
|
||||
->createQueryBuilder('penalty')
|
||||
->select('penalty')
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('penalty.user=:user AND penalty.start>=:start AND penalty.end <:end')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end);
|
||||
if($onlyvalidate)
|
||||
$qb->andWhere('penalty.validate=:validate')->setParameter('validate',true);
|
||||
|
||||
$penaltys=$qb->getQuery()->getResult();
|
||||
foreach($penaltys as $penalty) {
|
||||
$project=$penalty->getTask()->getProject();
|
||||
$idproject=$project->getId();
|
||||
$idservice=$project->getService()->getId();
|
||||
$activeproject=$project->getActive();
|
||||
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($idservice!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($idproject!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ne prendre que les projets actif/inactif
|
||||
if($this->get('session')->get('activeproject')!=$activeproject)
|
||||
continue;
|
||||
|
||||
if(!isset($tbevents[$idproject]))
|
||||
$tbevents[$idproject] = [];
|
||||
|
||||
$st=clone $penalty->getStart();
|
||||
while($st<$penalty->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
$idmonth=$st->format("Ym");
|
||||
|
||||
if(!isset($tbevents[$idproject][$idday])) {
|
||||
$tbevents[$idproject][$idday] = [
|
||||
"idproject"=>$idproject,
|
||||
"idmonth"=>$idmonth,
|
||||
"idday"=>$idday,
|
||||
"daycolor"=>$this->frmColorday($st->format("w")),
|
||||
"duration"=>0,
|
||||
"astreinte"=>0,
|
||||
];
|
||||
}
|
||||
|
||||
$tbevents[$idproject][$idday]["astreinte"]=1;
|
||||
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
return $tbevents;
|
||||
}
|
||||
|
||||
public function holiday(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$iduser=$this->getUser();
|
||||
$users=$em->getRepository("App:User")->findBy(["id"=>$iduser]);
|
||||
|
||||
$tbevents=[];
|
||||
foreach($users as $user) {
|
||||
$tmp=[
|
||||
"id" => $user->getId(),
|
||||
"user" => $user,
|
||||
"holidays" => [],
|
||||
"holidaystodevalidate" => [],
|
||||
];
|
||||
|
||||
// Congès à valider ou à dévalider
|
||||
$holidays = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Event','event')
|
||||
->from('App:Task','task')
|
||||
->Where('event.user=:user')
|
||||
->andWhere('event.validateholiday=:validate')
|
||||
->andWhere('task=event.task')
|
||||
->andWhere('task.nature=:nature')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('validate',!($this->get("session")->get("activeholiday")))
|
||||
->setParameter('nature',-200)
|
||||
->getQuery()->getResult();
|
||||
foreach($holidays as $holiday) {
|
||||
$tbholiday = [
|
||||
"id"=>$holiday->getId(),
|
||||
"start"=>$holiday->getStart(),
|
||||
"end"=>$holiday->getEnd()->sub(new \DateInterval('PT1M')),
|
||||
"task"=>$holiday->getTask()->getName(),
|
||||
"duration"=>$holiday->getDuration(),
|
||||
"validateholiday"=>$holiday->getValidateholiday(),
|
||||
];
|
||||
|
||||
array_push($tmp["holidays"],$tbholiday);
|
||||
}
|
||||
|
||||
array_push($tbevents,$tmp);
|
||||
}
|
||||
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView('Report/holiday.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents,
|
||||
"fgprint" => $request->query->get('fgprint'),
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'conges.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render('Report/holiday.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function activeholiday() {
|
||||
$this->get('session')->set('activeholiday',!$this->get('session')->get('activeholiday'));
|
||||
|
||||
return $this->redirectToRoute("app_holiday");
|
||||
}
|
||||
|
||||
private function frmDay($daynumber) {
|
||||
switch($daynumber) {
|
||||
case 0: return "D"; break;
|
||||
case 1: return "L"; break;
|
||||
case 2: return "M"; break;
|
||||
case 3: return "M"; break;
|
||||
case 4: return "J"; break;
|
||||
case 5: return "V"; break;
|
||||
case 6: return "S"; break;
|
||||
}
|
||||
}
|
||||
|
||||
private function frmColorday($daynumber) {
|
||||
switch($daynumber) {
|
||||
case 0: return "#888888"; break;
|
||||
case 1: return "#cccccc"; break;
|
||||
case 2: return "#cccccc"; break;
|
||||
case 3: return "#cccccc"; break;
|
||||
case 4: return "#cccccc"; break;
|
||||
case 5: return "#cccccc"; break;
|
||||
case 6: return "#888888"; break;
|
||||
}
|
||||
}
|
||||
}
|
156
src/schedule-2.0/src/Controller/SecurityController.php
Executable file
156
src/schedule-2.0/src/Controller/SecurityController.php
Executable file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
// src/OC/UserBundle/Controller/SecurityController.php;
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
||||
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
|
||||
|
||||
use jasig\phpcas\CAS;
|
||||
|
||||
class SecurityController extends AbstractController
|
||||
{
|
||||
public function login(Request $request, AuthenticationUtils $authenticationUtils)
|
||||
{
|
||||
$auth_mode=$this->getParameter("appAuth");
|
||||
switch($auth_mode) {
|
||||
case "MYSQL":
|
||||
return $this->loginMYSQL($request,$authenticationUtils);
|
||||
break;
|
||||
|
||||
case "CAS":
|
||||
return $this->loginCAS($request,$authenticationUtils);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function loginMYSQL(Request $request, AuthenticationUtils $authenticationUtils) {
|
||||
return $this->render('Home/login.html.twig', array(
|
||||
'last_username' => $authenticationUtils->getLastUsername(),
|
||||
'error' => $authenticationUtils->getLastAuthenticationError(),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function logincas(Request $request, AuthenticationUtils $authenticationUtils)
|
||||
{
|
||||
// Récupération de la cible de navigation
|
||||
$redirect = $request->get("redirect");
|
||||
|
||||
// Init Client CAS
|
||||
\phpCAS::setDebug('/var/www/html/schedule/var/log/cas.log');
|
||||
\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('casHost'), intval($this->getParameter('casPort')), is_null($this->getParameter('casPath')) ? '' : $this->getParameter('casPath'), false);
|
||||
\phpCAS::setNoCasServerValidation();
|
||||
|
||||
|
||||
// Authentification
|
||||
\phpCAS::forceAuthentication();
|
||||
|
||||
// Récupération UID
|
||||
$username = \phpCAS::getUser();
|
||||
|
||||
// Récupération Attribut
|
||||
$attributes = \phpCAS::getAttributes();
|
||||
dump($username);
|
||||
dump($attributes);
|
||||
|
||||
// Suppression des Attributs en tableaux
|
||||
foreach ($attributes as $key => $value) {
|
||||
if(is_array($value))
|
||||
unset($attributes[$key]);
|
||||
}
|
||||
|
||||
|
||||
// Rechercher l'utilisateur
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
if(isset($attributes[$this->getParameter('casUsername')]))
|
||||
$username = $attributes[$this->getParameter('casUsername')];
|
||||
|
||||
if(isset($attributes[$this->getParameter('casEmail')]))
|
||||
$email = $attributes[$this->getParameter('casEmail')];
|
||||
|
||||
if(isset($attributes[$this->getParameter('casLastname')]))
|
||||
$lastname = $attributes[$this->getParameter('casLastname')];
|
||||
|
||||
if(isset($attributes[$this->getParameter('casFirstname')]))
|
||||
$firstname = $attributes[$this->getParameter('casFirstname')];
|
||||
|
||||
$user = $em->getRepository('App:User')->findOneBy(array("username"=>$username));
|
||||
$exists = $user ? true : false;
|
||||
|
||||
if (!$exists) {
|
||||
$user = new User();
|
||||
|
||||
$user->setUsername($username);
|
||||
$user->setLastname($lastname);
|
||||
$user->setFirstname($firstname);
|
||||
$user->setEmail($email);
|
||||
|
||||
$user->setPassword("CASPWD-".$username);
|
||||
$user->setSalt("CASPWD-".$username);
|
||||
|
||||
$user->setRole("ROLE_USER");
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
}
|
||||
else {
|
||||
if(isset($lastname)) $user->setLastname($lastname);
|
||||
if(isset($firstname)) $user->setFirstname($firstname);
|
||||
if(isset($email)) $user->setEmail($email);
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
|
||||
// Autoconnexion
|
||||
// Récupérer le token de l'utilisateur
|
||||
$token = new UsernamePasswordToken($user, null, "main", $user->getRoles());
|
||||
$this->get("security.token_storage")->setToken($token);
|
||||
|
||||
// Simuler l'evenement de connexion
|
||||
$event = new InteractiveLoginEvent($request, $token);
|
||||
$dispatcher = new EventDispatcher();
|
||||
$dispatcher->dispatch("security.interactive_login", $event);
|
||||
|
||||
// Redirection
|
||||
if($redirect)
|
||||
return $this->redirect($redirect);
|
||||
else
|
||||
return $this->redirect($this->generateUrl('app_home'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function logout() {
|
||||
$this->get('security.token_storage')->setToken(null);
|
||||
$this->get('session')->invalidate();
|
||||
|
||||
return $this->redirect($this->generateUrl("cnous_portal_homepage"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function logoutcas() {
|
||||
// Init Client CAS
|
||||
\phpCAS::setDebug('/var/www/html/schedule/var/log/cas.log');
|
||||
\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('casHost'), intval($this->getParameter('casPort')), is_null($this->getParameter('casPath')) ? '' : $this->getParameter('casPath'), false);
|
||||
\phpCAS::setNoCasServerValidation();
|
||||
|
||||
|
||||
// Logout
|
||||
$url=$this->generateUrl('app_home', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
\phpCAS::logout(array("service"=>$url));
|
||||
}
|
||||
}
|
173
src/schedule-2.0/src/Controller/ServiceController.php
Executable file
173
src/schedule-2.0/src/Controller/ServiceController.php
Executable file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Service as Entity;
|
||||
use App\Form\ServiceType as Form;
|
||||
|
||||
class ServiceController extends AbstractController
|
||||
{
|
||||
private $data = "service";
|
||||
private $route = "app_service";
|
||||
private $render = "Service/";
|
||||
private $entity = "App:Service";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'services.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'service.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
184
src/schedule-2.0/src/Controller/TaskController.php
Executable file
184
src/schedule-2.0/src/Controller/TaskController.php
Executable file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\Task as Entity;
|
||||
use App\Form\TaskType as Form;
|
||||
|
||||
class TaskController extends AbstractController
|
||||
{
|
||||
private $data = "task";
|
||||
private $route = "app_task";
|
||||
private $render = "Task/";
|
||||
private $entity = "App:Task";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$services=$em->getRepository("App:Service")->findAllTaskActive($this->get('session')->get('activeproject'),$this->get('session')->get('idservice'));
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
"services" => $services,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]),
|
||||
'taches.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
"services" => $services,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'tache.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
public function activeproject() {
|
||||
$this->get('session')->set('activeproject',!$this->get('session')->get('activeproject'));
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
public function activeoffer() {
|
||||
$this->get('session')->set('activeoffer',!$this->get('session')->get('activeoffer'));
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
254
src/schedule-2.0/src/Controller/UserController.php
Executable file
254
src/schedule-2.0/src/Controller/UserController.php
Executable file
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
use App\Entity\User as Entity;
|
||||
use App\Form\UserType as Form;
|
||||
|
||||
class UserController extends AbstractController
|
||||
{
|
||||
private $data = "user";
|
||||
private $route = "app_user";
|
||||
private $render = "User/";
|
||||
private $entity = "App:User";
|
||||
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'utilisateurs.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit","appAuth"=>$this->getParameter("appAuth")));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
if($this->getParameter("appAuth")!="MYSQL") {
|
||||
$data->setPassword("nopassword");
|
||||
}
|
||||
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
$oldpassword=$data->getPassword();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update","appAuth"=>$this->getParameter("appAuth")));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
|
||||
// Si pas de changement de password on replace l'ancien
|
||||
if(!$data->getPassword()) {
|
||||
$data->setPassword($oldpassword);
|
||||
}
|
||||
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
"fgprint" => true,
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'utilisateur.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function profil(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$this->getUser();
|
||||
$oldpassword=$data->getPassword();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"profil","appAuth"=>$this->getParameter("appAuth")));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
|
||||
// Si pas de changement de password on replace l'ancien
|
||||
if(!$data->getPassword()) {
|
||||
$data->setPassword($oldpassword);
|
||||
}
|
||||
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute("app_home");
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'profil',
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
if($error)
|
||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
||||
else {
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
$this->refreshsession();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
protected function refreshsession() {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$tbusers=[];
|
||||
$haveuser=false;
|
||||
|
||||
$users=$em->getRepository('App:User')->findAll();
|
||||
foreach($users as $user) {
|
||||
if(in_array("ROLE_USER",$user->getRoles())) {
|
||||
if($user->getId()==$this->get('session')->get('iduser'))
|
||||
$haveuser=true;
|
||||
|
||||
$tmp=[
|
||||
"id"=>$user->getId(),
|
||||
"displayname"=>$user->getDisplayname()
|
||||
];
|
||||
array_push($tbusers,$tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$haveuser) $this->get('session')->set("iduser","all");
|
||||
|
||||
$this->get('session')->set('users',$tbusers);
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
$this->get('session')->getFlashBag()->clear();
|
||||
|
||||
$errors = $form->getErrors();
|
||||
foreach( $errors as $error ) {
|
||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
546
src/schedule-2.0/src/Controller/ValidationController.php
Executable file
546
src/schedule-2.0/src/Controller/ValidationController.php
Executable file
@@ -0,0 +1,546 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||
|
||||
class ValidationController extends AbstractController
|
||||
{
|
||||
private $knpSnappy;
|
||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
||||
|
||||
public function validation(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$nbmonth=$this->get("session")->get("nbmonth");
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
|
||||
if($iduser=="all") {
|
||||
$users=$em->getRepository("App:User")->findAll();
|
||||
}
|
||||
else {
|
||||
$users=$em->getRepository("App:User")->findBy(["id"=>$iduser]);
|
||||
}
|
||||
|
||||
$maxend=new \Datetime();
|
||||
$maxend->add(new \DateInterval('P1M'));
|
||||
$maxend->modify('first Monday');
|
||||
|
||||
$tbevents=[];
|
||||
foreach($users as $user) {
|
||||
if(in_array("ROLE_USER",$user->getRoles())) {
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($user->getService()->getId()!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmp=[
|
||||
"id" => $user->getId(),
|
||||
"user" => $user,
|
||||
"events" => [],
|
||||
];
|
||||
|
||||
// On recherche le dernier evenement non congés validé pour ce user
|
||||
$eventstart = $em
|
||||
->createQueryBuilder('event')
|
||||
->select("event")
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user')
|
||||
->andWhere('event.validate=true')
|
||||
->setParameter('user',$user)
|
||||
->setMaxResults(1)
|
||||
->orderBy('event.start', 'DESC')
|
||||
->getQuery()->getOneOrNullResult();
|
||||
if(!$eventstart) {
|
||||
// Sinon on recherche le premier evenement de l'utilisateur
|
||||
$eventstart=$em->getRepository("App:Event")->findOneBy(["user"=>$user],["start"=>"ASC"]);
|
||||
}
|
||||
|
||||
// On formate le tableau des jours
|
||||
$start=clone $eventstart->getStart();
|
||||
if($start->format("w")!=1) $start->modify('last Monday');
|
||||
$end=clone $maxend;
|
||||
|
||||
while($start<$end) {
|
||||
$idday=$start->format("Ymd");
|
||||
$idmonth=$start->format("Ym");
|
||||
|
||||
// Si le lundi on regarde s'il une tache de validé dans la semaine
|
||||
if($start->format("w")==1) {
|
||||
$validate=false;
|
||||
|
||||
$endweek=clone $start;
|
||||
$endweek->modify('next Monday');
|
||||
|
||||
$event = $em
|
||||
->createQueryBuilder('event')
|
||||
->select("event.id")
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user')
|
||||
->andWhere('event.start>=:start')
|
||||
->andWhere('event.end<:end')
|
||||
->andWhere('event.validate=true')
|
||||
->setParameter('user',$user)
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$endweek)
|
||||
->getQuery()->getResult();
|
||||
if($event) {
|
||||
$validate=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$tmp["events"][$idday] = [
|
||||
"date"=>clone $start,
|
||||
"allday"=>false,
|
||||
"colorday"=>"",
|
||||
"descriptionday"=>"",
|
||||
"am"=>false,
|
||||
"coloram"=>"",
|
||||
"descriptionam"=>"",
|
||||
"ap"=>false,
|
||||
"colorap"=>"",
|
||||
"descriptionap"=>"",
|
||||
"validate"=>$validate,
|
||||
"astreinte"=>false,
|
||||
"colorastreinte"=>"",
|
||||
"descriptionastreinte"=>"",
|
||||
];
|
||||
|
||||
$start->add(new \DateInterval('P1D'));
|
||||
}
|
||||
|
||||
// On formate le tableau des event
|
||||
$start=clone $eventstart->getStart();
|
||||
if($start->format("w")!=1) $start->modify('last Monday');
|
||||
$end=clone $maxend;
|
||||
|
||||
$events = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user AND event.start>=:start AND event.end <:end')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($events as $event) {
|
||||
$idproject=$event->getTask()->getProject()->getId();
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($idproject!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
$st=clone $event->getStart();
|
||||
while($st<$event->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
if($event->getAllday()) {
|
||||
$tmp["events"][$idday]["allday"]=true;
|
||||
$tmp["events"][$idday]["colorday"]=$event->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionday"]=strtoupper($event->getTask()->getDisplayname())."\n\n".$event->getDescription();
|
||||
}
|
||||
else {
|
||||
// Matin ou après-midi ?
|
||||
$time=$event->getStart()->format("H");
|
||||
if($time==9) {
|
||||
$tmp["events"][$idday]["am"]=true;
|
||||
$tmp["events"][$idday]["coloram"]=$event->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionam"]=strtoupper($event->getTask()->getDisplayname())."\n\n".$event->getDescription();
|
||||
}
|
||||
else {
|
||||
$tmp["events"][$idday]["ap"]=true;
|
||||
$tmp["events"][$idday]["colorap"]=$event->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionap"]=strtoupper($event->getTask()->getDisplayname())."\n\n".$event->getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
// On formate le tableau des astreintes
|
||||
$start=clone $eventstart->getStart();
|
||||
if($start->format("w")!=1) $start->modify('last Monday');
|
||||
$end=clone $maxend;
|
||||
|
||||
$penaltys = $em
|
||||
->createQueryBuilder('penalty')
|
||||
->select('penalty')
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('penalty.user=:user AND penalty.start>=:start AND penalty.end <:end')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($penaltys as $penalty) {
|
||||
$idproject=$penalty->getTask()->getProject()->getId();
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($idproject!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
|
||||
$st=clone $penalty->getStart();
|
||||
while($st<$penalty->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
if($penalty->getAllday()) {
|
||||
$tmp["events"][$idday]["astreinte"]=true;
|
||||
$tmp["events"][$idday]["colorastreinte"]=$penalty->getTask()->getColor();
|
||||
$tmp["events"][$idday]["descriptionastreinte"]=strtoupper($penalty->getTask()->getDisplayname())."\n\n".$penalty->getDescription();
|
||||
}
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
// On formate le tableau des jours fériés
|
||||
$start=clone $eventstart->getStart();
|
||||
if($start->format("w")!=1) $start->modify('last Monday');
|
||||
$end=clone $maxend;
|
||||
|
||||
$breakdays = $em
|
||||
->createQueryBuilder('breakday')
|
||||
->select('breakday')
|
||||
->from('App:Breakday','breakday')
|
||||
->Where('breakday.start>=:start AND breakday.end <:end')
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($breakdays as $breakday) {
|
||||
$st=clone $breakday->getStart();
|
||||
while($st<$breakday->getEnd()) {
|
||||
$idday=$st->format("Ymd");
|
||||
$tmp["events"][$idday]["allday"]=true;
|
||||
$tmp["events"][$idday]["colorday"]="#6c7a89";
|
||||
$tmp["events"][$idday]["descriptionday"]="Jour Férié";
|
||||
|
||||
$st->add(new \DateInterval('P1D'));
|
||||
}
|
||||
}
|
||||
|
||||
array_push($tbevents,$tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView('Validation/validation.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents,
|
||||
"fgprint" => $request->query->get('fgprint'),
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'validation.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render('Validation/validation.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(Request $request){
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
// Récupération des variables envoyées en post
|
||||
$iduser = $request->request->get('iduser');
|
||||
$day = $request->request->get('day');
|
||||
$start= new \Datetime($day);
|
||||
$end=clone $start;
|
||||
$end->modify('next Saturday');
|
||||
|
||||
// Somme dans la semaine
|
||||
$duration=0;
|
||||
|
||||
// Somme des jours fériés de la semaine
|
||||
$breakdays = $em
|
||||
->createQueryBuilder('breakday')
|
||||
->select("breakday")
|
||||
->from('App:Breakday','breakday')
|
||||
->Where('breakday.start>=:start')
|
||||
->andWhere('breakday.end<=:end')
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($breakdays as $breakday) {
|
||||
$duration++;
|
||||
}
|
||||
|
||||
// On recherche l'ensemble des évènements de la semaine
|
||||
$events = $em
|
||||
->createQueryBuilder('event')
|
||||
->select("event")
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user')
|
||||
->andWhere('event.start>=:start')
|
||||
->andWhere('event.end<=:end')
|
||||
->setParameter('user',$iduser)
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($events as $event) {
|
||||
$duration+=$event->getDuration();
|
||||
|
||||
// Si congès = le congès doit etre validé
|
||||
if($event->getTask()->getNature()->getId()==-200)
|
||||
{
|
||||
if(!$event->getValidateholiday()) {
|
||||
$output=["return"=>"KO","error"=>"Validation impossible = présence de congés non validés"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($duration!= 5) {
|
||||
$output=["return"=>"KO","error"=>"Validation impossible = semaine incomplète"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
// OK = On valide les evenements
|
||||
foreach($events as $event) {
|
||||
$event->setValidate(true);
|
||||
$em->persist($event);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
// OK = On valide les astreintes
|
||||
$start= new \Datetime($day);
|
||||
$end=clone $start;
|
||||
$end->modify('next Monday');
|
||||
$penaltys = $em
|
||||
->createQueryBuilder('penalty')
|
||||
->select("penalty")
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('penalty.user=:user')
|
||||
->andWhere('penalty.start>=:start')
|
||||
->andWhere('penalty.end<=:end')
|
||||
->setParameter('user',$iduser)
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($penaltys as $penalty) {
|
||||
$penalty->setValidate(true);
|
||||
$em->persist($penalty);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
$output=[];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function devalidate(Request $request){
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
// Récupération des variables envoyées en post
|
||||
$iduser = $request->request->get('iduser');
|
||||
$day = $request->request->get('day');
|
||||
$start= new \Datetime($day);
|
||||
$end=clone $start;
|
||||
$end->modify('next Saturday');
|
||||
|
||||
// On recherche l'ensemble des évènements de la semaine
|
||||
$events = $em
|
||||
->createQueryBuilder('event')
|
||||
->select("event")
|
||||
->from('App:Event','event')
|
||||
->Where('event.user=:user')
|
||||
->andWhere('event.start>=:start')
|
||||
->andWhere('event.end<=:end')
|
||||
->setParameter('user',$iduser)
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
|
||||
/*
|
||||
foreach($events as $event) {
|
||||
// Si congès = le congès doit etre non validé
|
||||
if($event->getTask()->getNature()->getId()==-200)
|
||||
{
|
||||
if($event->getValidateholiday()) {
|
||||
$output=["return"=>"KO","error"=>"Dévalidation impossible = présence de congés validés"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// OK = On devalide les evenements
|
||||
foreach($events as $event) {
|
||||
$event->setValidate(false);
|
||||
$em->persist($event);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
// OK = On devalide les astreintes
|
||||
$start= new \Datetime($day);
|
||||
$end=clone $start;
|
||||
$end->modify('next Monday');
|
||||
$penaltys = $em
|
||||
->createQueryBuilder('penalty')
|
||||
->select("penalty")
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('penalty.user=:user')
|
||||
->andWhere('penalty.start>=:start')
|
||||
->andWhere('penalty.end<=:end')
|
||||
->setParameter('user',$iduser)
|
||||
->setParameter('start',$start)
|
||||
->setParameter('end',$end)
|
||||
->getQuery()->getResult();
|
||||
foreach($penaltys as $penalty) {
|
||||
$penalty->setValidate(false);
|
||||
$em->persist($penalty);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
$output=[];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function validationholiday(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
|
||||
if($iduser=="all") {
|
||||
$users=$em->getRepository("App:User")->findAll();
|
||||
}
|
||||
else {
|
||||
$users=$em->getRepository("App:User")->findBy(["id"=>$iduser]);
|
||||
}
|
||||
|
||||
$tbevents=[];
|
||||
foreach($users as $user) {
|
||||
if(in_array("ROLE_USER",$user->getRoles())) {
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($user->getService()->getId()!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmp=[
|
||||
"id" => $user->getId(),
|
||||
"user" => $user,
|
||||
"holidays" => [],
|
||||
"holidaystodevalidate" => [],
|
||||
];
|
||||
|
||||
// Congès à valider ou à dévalider
|
||||
$holidays = $em
|
||||
->createQueryBuilder('event')
|
||||
->select('event')
|
||||
->from('App:Event','event')
|
||||
->from('App:Task','task')
|
||||
->Where('event.user=:user')
|
||||
->andWhere('event.validateholiday=:validate')
|
||||
->andWhere('task=event.task')
|
||||
->andWhere('task.nature=:nature')
|
||||
->setParameter('user',$user->getId())
|
||||
->setParameter('validate',!($this->get("session")->get("activeholiday")))
|
||||
->setParameter('nature',-200)
|
||||
->getQuery()->getResult();
|
||||
foreach($holidays as $holiday) {
|
||||
// On ne peut dévalider les congès que sur une semaine non validé
|
||||
if(!$this->get("session")->get("activeholiday")&&$holiday->getValidate())
|
||||
continue;
|
||||
|
||||
$tbholiday = [
|
||||
"id"=>$holiday->getId(),
|
||||
"start"=>$holiday->getStart(),
|
||||
"end"=>$holiday->getEnd()->sub(new \DateInterval('PT1M')),
|
||||
"task"=>$holiday->getTask()->getName(),
|
||||
"duration"=>$holiday->getDuration(),
|
||||
"validateholiday"=>$holiday->getValidateholiday(),
|
||||
];
|
||||
|
||||
array_push($tmp["holidays"],$tbholiday);
|
||||
}
|
||||
|
||||
array_push($tbevents,$tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($request->query->get('fgprint')) {
|
||||
$render = $this->renderView('Validation/validationholiday.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents,
|
||||
"fgprint" => $request->query->get('fgprint'),
|
||||
]);
|
||||
|
||||
return new PdfResponse(
|
||||
$this->knpSnappy->getOutputFromHtml($render),
|
||||
'validationconges.pdf'
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $this->render('Validation/validationholiday.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => ($this->getUser()),
|
||||
"users" => $tbevents
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function validateholiday(Request $request){
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
// Récupération des variables envoyées en post
|
||||
$id = $request->request->get('id');
|
||||
$event=$em->getRepository("App:Event")->find($id);
|
||||
if($event) {
|
||||
$event->setValidateholiday(true);
|
||||
$em->persist($event);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
$output=[];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function devalidateholiday(Request $request){
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
// Récupération des variables envoyées en post
|
||||
$id = $request->request->get('id');
|
||||
$event=$em->getRepository("App:Event")->find($id);
|
||||
if($event) {
|
||||
if($event->getValidate()) {
|
||||
$output=["return"=>"KO","error"=>"Dévalidation impossible = semaine de travail validée"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
$event->setValidateholiday(false);
|
||||
$em->persist($event);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
$output=[];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function activeholiday() {
|
||||
$this->get('session')->set('activeholiday',!$this->get('session')->get('activeholiday'));
|
||||
|
||||
return $this->redirectToRoute("app_validationholiday");
|
||||
}
|
||||
|
||||
}
|
0
src/schedule-2.0/src/Entity/.gitignore
vendored
Normal file
0
src/schedule-2.0/src/Entity/.gitignore
vendored
Normal file
71
src/schedule-2.0/src/Entity/Breakday.php
Normal file
71
src/schedule-2.0/src/Entity/Breakday.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Event
|
||||
*
|
||||
* @ORM\Table(name="breakday")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\BreakdayRepository")
|
||||
* @UniqueEntity(
|
||||
* fields={"start"},
|
||||
* message="Jour férié déjà existant"
|
||||
* )
|
||||
*/
|
||||
class Breakday
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="start", type="datetime", unique=true)
|
||||
*
|
||||
*/
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="end", type="datetime")
|
||||
*
|
||||
*/
|
||||
private $end;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getStart(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function setStart(\DateTimeInterface $start): self
|
||||
{
|
||||
$this->start = $start;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
public function setEnd(\DateTimeInterface $end): self
|
||||
{
|
||||
$this->end = $end;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
384
src/schedule-2.0/src/Entity/Cron.php
Normal file
384
src/schedule-2.0/src/Entity/Cron.php
Normal file
@@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Cron
|
||||
*
|
||||
* @ORM\Table(name="cron")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\CronRepository")
|
||||
*/
|
||||
class Cron
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="command", type="string", nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
*
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $statut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
*/
|
||||
private $submitdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $startexecdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $endexecdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $nextexecdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $repeatcall;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $repeatexec;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $repeatinterval;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $jsonargument;
|
||||
|
||||
private $statutlabel;
|
||||
|
||||
// A garder pour forcer l'id en init
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// A garder pour récupérer le label du statut
|
||||
public function getStatutlabel()
|
||||
{
|
||||
switch($this->statut) {
|
||||
case 0: $this->statutlabel="A éxécuter"; break;
|
||||
case 1: $this->statutlabel="Exécution en cours"; break;
|
||||
case 2: $this->statutlabel="OK"; break;
|
||||
case 3: $this->statutlabel="KO"; break;
|
||||
}
|
||||
return $this->statutlabel;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->submitdate = new \DateTime();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set command
|
||||
*
|
||||
* @param string $command
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setCommand($command)
|
||||
{
|
||||
$this->command = $command;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get command
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommand()
|
||||
{
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set statut
|
||||
*
|
||||
* @param integer $statut
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setStatut($statut)
|
||||
{
|
||||
$this->statut = $statut;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get statut
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStatut()
|
||||
{
|
||||
return $this->statut;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set submitdate
|
||||
*
|
||||
* @param \DateTime $submitdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setSubmitdate($submitdate)
|
||||
{
|
||||
$this->submitdate = $submitdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get submitdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getSubmitdate()
|
||||
{
|
||||
return $this->submitdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set startexecdate
|
||||
*
|
||||
* @param \DateTime $startexecdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setStartexecdate($startexecdate)
|
||||
{
|
||||
$this->startexecdate = $startexecdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get startexecdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getStartexecdate()
|
||||
{
|
||||
return $this->startexecdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set endexecdate
|
||||
*
|
||||
* @param \DateTime $endexecdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setEndexecdate($endexecdate)
|
||||
{
|
||||
$this->endexecdate = $endexecdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get endexecdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getEndexecdate()
|
||||
{
|
||||
return $this->endexecdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set nextexecdate
|
||||
*
|
||||
* @param \DateTime $nextexecdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setNextexecdate($nextexecdate)
|
||||
{
|
||||
$this->nextexecdate = $nextexecdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get nextexecdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getNextexecdate()
|
||||
{
|
||||
return $this->nextexecdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repeatcall
|
||||
*
|
||||
* @param integer $repeatcall
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setRepeatcall($repeatcall)
|
||||
{
|
||||
$this->repeatcall = $repeatcall;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeatcall
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRepeatcall()
|
||||
{
|
||||
return $this->repeatcall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repeatexec
|
||||
*
|
||||
* @param integer $repeatexec
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setRepeatexec($repeatexec)
|
||||
{
|
||||
$this->repeatexec = $repeatexec;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeatexec
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRepeatexec()
|
||||
{
|
||||
return $this->repeatexec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repeatinterval
|
||||
*
|
||||
* @param integer $repeatinterval
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setRepeatinterval($repeatinterval)
|
||||
{
|
||||
$this->repeatinterval = $repeatinterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeatinterval
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRepeatinterval()
|
||||
{
|
||||
return $this->repeatinterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set jsonargument
|
||||
*
|
||||
* @param string $jsonargument
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setJsonargument($jsonargument)
|
||||
{
|
||||
$this->jsonargument = $jsonargument;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get jsonargument
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsonargument()
|
||||
{
|
||||
return $this->jsonargument;
|
||||
}
|
||||
}
|
107
src/schedule-2.0/src/Entity/Customer.php
Normal file
107
src/schedule-2.0/src/Entity/Customer.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Customer
|
||||
*
|
||||
* @ORM\Table(name="customer")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
|
||||
*/
|
||||
class Customer
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string")
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="keypass", type="string", nullable=true)
|
||||
*
|
||||
*/
|
||||
private $keypass;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Project", mappedBy="customer", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $projects;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->projects = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKeypass(): ?string
|
||||
{
|
||||
return $this->keypass;
|
||||
}
|
||||
|
||||
public function setKeypass(?string $keypass): self
|
||||
{
|
||||
$this->keypass = $keypass;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Project[]
|
||||
*/
|
||||
public function getProjects(): Collection
|
||||
{
|
||||
return $this->projects;
|
||||
}
|
||||
|
||||
public function addProject(Project $project): self
|
||||
{
|
||||
if (!$this->projects->contains($project)) {
|
||||
$this->projects[] = $project;
|
||||
$project->setService($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProject(Project $project): self
|
||||
{
|
||||
if ($this->projects->contains($project)) {
|
||||
$this->projects->removeElement($project);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($project->getService() === $this) {
|
||||
$project->setService(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
194
src/schedule-2.0/src/Entity/Event.php
Normal file
194
src/schedule-2.0/src/Entity/Event.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Event
|
||||
*
|
||||
* @ORM\Table(name="event", indexes={
|
||||
* @ORM\Index(name="idxuser", columns={"user_id", "start", "end"}),
|
||||
* @ORM\Index(name="idxdate", columns={"start", "end"}),
|
||||
* @ORM\Index(name="idxusertask", columns={"user_id","task_id","start", "end"}),
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass="App\Repository\EventRepository")
|
||||
*/
|
||||
class Event
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="duration", type="decimal", scale=2)
|
||||
*
|
||||
*/
|
||||
private $duration;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="start", type="datetime")
|
||||
*
|
||||
*/
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="end", type="datetime")
|
||||
*
|
||||
*/
|
||||
private $end;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="allday", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $allday;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="validate", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $validate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="validateholiday", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $validateholiday;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="events")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Task", inversedBy="events")
|
||||
*/
|
||||
private $task;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getDuration(): ?string
|
||||
{
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
public function setDuration(string $duration): self
|
||||
{
|
||||
$this->duration = $duration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStart(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function setStart(\DateTimeInterface $start): self
|
||||
{
|
||||
$this->start = $start;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
public function setEnd(\DateTimeInterface $end): self
|
||||
{
|
||||
$this->end = $end;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAllday(): ?bool
|
||||
{
|
||||
return $this->allday;
|
||||
}
|
||||
|
||||
public function setAllday(bool $allday): self
|
||||
{
|
||||
$this->allday = $allday;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidate(): ?bool
|
||||
{
|
||||
return $this->validate;
|
||||
}
|
||||
|
||||
public function setValidate(bool $validate): self
|
||||
{
|
||||
$this->validate = $validate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): self
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTask(): ?Task
|
||||
{
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
public function setTask(?Task $task): self
|
||||
{
|
||||
$this->task = $task;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidateholiday(): ?bool
|
||||
{
|
||||
return $this->validateholiday;
|
||||
}
|
||||
|
||||
public function setValidateholiday(bool $validateholiday): self
|
||||
{
|
||||
$this->validateholiday = $validateholiday;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
161
src/schedule-2.0/src/Entity/Job.php
Normal file
161
src/schedule-2.0/src/Entity/Job.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Job
|
||||
*
|
||||
* @ORM\Table(name="job")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\JobRepository")
|
||||
*/
|
||||
class Job
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string")
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="description", type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="type", type="string")
|
||||
*
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="User", mappedBy="jobs")
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Userproject", mappedBy="job", cascade={"persist"}, orphanRemoval=true)
|
||||
*/
|
||||
private $userprojects;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->users = new ArrayCollection();
|
||||
$this->userprojects = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): self
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(string $type): self
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|User[]
|
||||
*/
|
||||
public function getUsers(): Collection
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
public function addUser(User $user): self
|
||||
{
|
||||
if (!$this->users->contains($user)) {
|
||||
$this->users[] = $user;
|
||||
$user->addJob($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUser(User $user): self
|
||||
{
|
||||
if ($this->users->contains($user)) {
|
||||
$this->users->removeElement($user);
|
||||
$user->removeJob($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Userproject[]
|
||||
*/
|
||||
public function getUserprojects(): Collection
|
||||
{
|
||||
return $this->userprojects;
|
||||
}
|
||||
|
||||
public function addUserproject(Userproject $userproject): self
|
||||
{
|
||||
if (!$this->userprojects->contains($userproject)) {
|
||||
$this->userprojects[] = $userproject;
|
||||
$userproject->setJob($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUserproject(Userproject $userproject): self
|
||||
{
|
||||
if ($this->userprojects->contains($userproject)) {
|
||||
$this->userprojects->removeElement($userproject);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($userproject->getJob() === $this) {
|
||||
$userproject->setJob(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
108
src/schedule-2.0/src/Entity/Nature.php
Normal file
108
src/schedule-2.0/src/Entity/Nature.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Nature
|
||||
*
|
||||
* @ORM\Table(name="nature")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\NatureRepository")
|
||||
*/
|
||||
class Nature
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string")
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="isvacation", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $isvacation;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Task", mappedBy="nature", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $tasks;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->tasks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Task[]
|
||||
*/
|
||||
public function getTasks(): Collection
|
||||
{
|
||||
return $this->tasks;
|
||||
}
|
||||
|
||||
public function addTask(Task $task): self
|
||||
{
|
||||
if (!$this->tasks->contains($task)) {
|
||||
$this->tasks[] = $task;
|
||||
$task->setNature($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeTask(Task $task): self
|
||||
{
|
||||
if ($this->tasks->contains($task)) {
|
||||
$this->tasks->removeElement($task);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($task->getNature() === $this) {
|
||||
$task->setNature(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsvacation(): ?bool
|
||||
{
|
||||
return $this->isvacation;
|
||||
}
|
||||
|
||||
public function setIsvacation(bool $isvacation): self
|
||||
{
|
||||
$this->isvacation = $isvacation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
162
src/schedule-2.0/src/Entity/Offer.php
Normal file
162
src/schedule-2.0/src/Entity/Offer.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Offer
|
||||
*
|
||||
* @ORM\Table(name="offer")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\OfferRepository")
|
||||
*/
|
||||
class Offer
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string")
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ref", type="string", nullable=true)
|
||||
*
|
||||
*/
|
||||
private $ref;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="quantity", type="decimal", scale=2)
|
||||
*
|
||||
*/
|
||||
private $quantity;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="pu", type="decimal", scale=2)
|
||||
*
|
||||
*/
|
||||
private $pu;
|
||||
private $total;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="validate", type="decimal", scale=2, nullable=true)
|
||||
*
|
||||
*/
|
||||
private $validate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Project", inversedBy="offers")
|
||||
*/
|
||||
private $project;
|
||||
|
||||
public function getTotal()
|
||||
{
|
||||
return $this->quantity*$this->pu;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRef(): ?string
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
public function setRef(string $ref): self
|
||||
{
|
||||
$this->ref = $ref;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuantity(): ?string
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
public function setQuantity(string $quantity): self
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPu(): ?string
|
||||
{
|
||||
return $this->pu;
|
||||
}
|
||||
|
||||
public function setPu(string $pu): self
|
||||
{
|
||||
$this->pu = $pu;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidate(): ?string
|
||||
{
|
||||
return $this->validate;
|
||||
}
|
||||
|
||||
public function setValidate(string $validate): self
|
||||
{
|
||||
$this->validate = $validate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): self
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProject(): ?Project
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function setProject(?Project $project): self
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
171
src/schedule-2.0/src/Entity/Penalty.php
Normal file
171
src/schedule-2.0/src/Entity/Penalty.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Penalty
|
||||
*
|
||||
* @ORM\Table(name="penalty")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\PenaltyRepository")
|
||||
*/
|
||||
class Penalty
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="duration", type="decimal", scale=2)
|
||||
*
|
||||
*/
|
||||
private $duration;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="start", type="datetime")
|
||||
*
|
||||
*/
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="end", type="datetime")
|
||||
*
|
||||
*/
|
||||
private $end;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="allday", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $allday;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="validate", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $validate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="penaltys")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Task", inversedBy="penaltys")
|
||||
*/
|
||||
private $task;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getDuration(): ?string
|
||||
{
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
public function setDuration(string $duration): self
|
||||
{
|
||||
$this->duration = $duration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStart(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function setStart(\DateTimeInterface $start): self
|
||||
{
|
||||
$this->start = $start;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
public function setEnd(\DateTimeInterface $end): self
|
||||
{
|
||||
$this->end = $end;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAllday(): ?bool
|
||||
{
|
||||
return $this->allday;
|
||||
}
|
||||
|
||||
public function setAllday(bool $allday): self
|
||||
{
|
||||
$this->allday = $allday;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidate(): ?bool
|
||||
{
|
||||
return $this->validate;
|
||||
}
|
||||
|
||||
public function setValidate(bool $validate): self
|
||||
{
|
||||
$this->validate = $validate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): self
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTask(): ?Task
|
||||
{
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
public function setTask(?Task $task): self
|
||||
{
|
||||
$this->task = $task;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
224
src/schedule-2.0/src/Entity/Project.php
Normal file
224
src/schedule-2.0/src/Entity/Project.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Project
|
||||
*
|
||||
* @ORM\Table(name="project")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\ProjectRepository")
|
||||
*/
|
||||
class Project
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string")
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
private $displayname;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="projects")
|
||||
*/
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Service", inversedBy="projects")
|
||||
*/
|
||||
private $service;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Offer", mappedBy="project", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $offers;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Task", mappedBy="project", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $tasks;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Userproject", mappedBy="project", cascade={"persist"}, orphanRemoval=true)
|
||||
*/
|
||||
private $userprojects;
|
||||
|
||||
|
||||
public function getDisplayname(): ?string
|
||||
{
|
||||
return $this->customer->getName()." - ".$this->name;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->offers = new ArrayCollection();
|
||||
$this->task = new ArrayCollection();
|
||||
$this->tasks = new ArrayCollection();
|
||||
$this->userprojects = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): self
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCustomer(): ?Customer
|
||||
{
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
public function setCustomer(?Customer $customer): self
|
||||
{
|
||||
$this->customer = $customer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getService(): ?Service
|
||||
{
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
public function setService(?Service $service): self
|
||||
{
|
||||
$this->service = $service;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Offer[]
|
||||
*/
|
||||
public function getOffers(): Collection
|
||||
{
|
||||
return $this->offers;
|
||||
}
|
||||
|
||||
public function addOffer(Offer $offer): self
|
||||
{
|
||||
if (!$this->offers->contains($offer)) {
|
||||
$this->offers[] = $offer;
|
||||
$offer->setProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeOffer(Offer $offer): self
|
||||
{
|
||||
if ($this->offers->contains($offer)) {
|
||||
$this->offers->removeElement($offer);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($offer->getProject() === $this) {
|
||||
$offer->setProject(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Task[]
|
||||
*/
|
||||
public function getTasks(): Collection
|
||||
{
|
||||
return $this->tasks;
|
||||
}
|
||||
|
||||
public function addTask(Task $task): self
|
||||
{
|
||||
if (!$this->tasks->contains($task)) {
|
||||
$this->tasks[] = $task;
|
||||
$task->setProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeTask(Task $task): self
|
||||
{
|
||||
if ($this->tasks->contains($task)) {
|
||||
$this->tasks->removeElement($task);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($task->getProject() === $this) {
|
||||
$task->setProject(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Userproject[]
|
||||
*/
|
||||
public function getUserprojects(): Collection
|
||||
{
|
||||
return $this->userprojects;
|
||||
}
|
||||
|
||||
public function addUserproject(Userproject $userproject): self
|
||||
{
|
||||
if (!$this->userprojects->contains($userproject)) {
|
||||
$this->userprojects[] = $userproject;
|
||||
$userproject->setProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUserproject(Userproject $userproject): self
|
||||
{
|
||||
if ($this->userprojects->contains($userproject)) {
|
||||
$this->userprojects->removeElement($userproject);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($userproject->getProject() === $this) {
|
||||
$userproject->setProject(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
144
src/schedule-2.0/src/Entity/Service.php
Normal file
144
src/schedule-2.0/src/Entity/Service.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Service
|
||||
*
|
||||
* @ORM\Table(name="service")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\ServiceRepository")
|
||||
*/
|
||||
class Service
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string")
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="User", mappedBy="service", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $users;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Project", mappedBy="service", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $projects;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->users = new ArrayCollection();
|
||||
$this->projects = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): self
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|User[]
|
||||
*/
|
||||
public function getUsers(): Collection
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
public function addUser(User $user): self
|
||||
{
|
||||
if (!$this->users->contains($user)) {
|
||||
$this->users[] = $user;
|
||||
$user->setService($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUser(User $user): self
|
||||
{
|
||||
if ($this->users->contains($user)) {
|
||||
$this->users->removeElement($user);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($user->getService() === $this) {
|
||||
$user->setService(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Project[]
|
||||
*/
|
||||
public function getProjects(): Collection
|
||||
{
|
||||
return $this->projects;
|
||||
}
|
||||
|
||||
public function addProject(Project $project): self
|
||||
{
|
||||
if (!$this->projects->contains($project)) {
|
||||
$this->projects[] = $project;
|
||||
$project->setService($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProject(Project $project): self
|
||||
{
|
||||
if ($this->projects->contains($project)) {
|
||||
$this->projects->removeElement($project);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($project->getService() === $this) {
|
||||
$project->setService(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
238
src/schedule-2.0/src/Entity/Task.php
Normal file
238
src/schedule-2.0/src/Entity/Task.php
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Task
|
||||
*
|
||||
* @ORM\Table(name="task")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\TaskRepository")
|
||||
*/
|
||||
class Task
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string")
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="color", type="string", nullable=true)
|
||||
*
|
||||
*/
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="quantity", type="decimal", scale=2, nullable=true)
|
||||
*
|
||||
*/
|
||||
private $quantity;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="validate", type="decimal", scale=2, nullable=true)
|
||||
*
|
||||
*/
|
||||
private $validate;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Project", inversedBy="tasks")
|
||||
*/
|
||||
private $project;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Nature", inversedBy="tasks")
|
||||
*/
|
||||
private $nature;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Event", mappedBy="task", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $events;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Penalty", mappedBy="task", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $penaltys;
|
||||
|
||||
/**
|
||||
* Calculate Displayname
|
||||
*/
|
||||
public function getDisplayname(): ?string
|
||||
{
|
||||
return $this->project->getCustomer()->getName()."-".$this->project->getName()."-".$this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate Duration
|
||||
*/
|
||||
public function getDuration($end): ?string
|
||||
{
|
||||
$this->duration=0;
|
||||
foreach($this->getEvents() as $event) {
|
||||
if($event->getEnd()<=$end)
|
||||
$this->duration+=$event->getDuration();
|
||||
}
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->events = new ArrayCollection();
|
||||
$this->penaltys = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getColor(): ?string
|
||||
{
|
||||
if($this->color&&$this->color!="#")
|
||||
return $this->color;
|
||||
else
|
||||
return "#3788d8";
|
||||
}
|
||||
|
||||
public function setColor(string $color): self
|
||||
{
|
||||
$this->color = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuantity(): ?string
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
public function setQuantity(string $quantity): self
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidate(): ?string
|
||||
{
|
||||
return $this->validate;
|
||||
}
|
||||
|
||||
public function setValidate(?string $validate): self
|
||||
{
|
||||
$this->validate = $validate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProject(): ?Project
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function setProject(?Project $project): self
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNature(): ?Nature
|
||||
{
|
||||
return $this->nature;
|
||||
}
|
||||
|
||||
public function setNature(?Nature $nature): self
|
||||
{
|
||||
$this->nature = $nature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Event[]
|
||||
*/
|
||||
public function getEvents(): Collection
|
||||
{
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
public function addEvent(Event $event): self
|
||||
{
|
||||
if (!$this->events->contains($event)) {
|
||||
$this->events[] = $event;
|
||||
$event->setTask($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeEvent(Event $event): self
|
||||
{
|
||||
if ($this->events->contains($event)) {
|
||||
$this->events->removeElement($event);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($event->getTask() === $this) {
|
||||
$event->setTask(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Penalty[]
|
||||
*/
|
||||
public function getPenaltys(): Collection
|
||||
{
|
||||
return $this->penaltys;
|
||||
}
|
||||
|
||||
public function addPenalty(Penalty $penalty): self
|
||||
{
|
||||
if (!$this->penaltys->contains($penalty)) {
|
||||
$this->penaltys[] = $penalty;
|
||||
$penalty->setTask($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePenalty(Penalty $penalty): self
|
||||
{
|
||||
if ($this->penaltys->contains($penalty)) {
|
||||
$this->penaltys->removeElement($penalty);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($penalty->getTask() === $this) {
|
||||
$penalty->setTask(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
412
src/schedule-2.0/src/Entity/User.php
Normal file
412
src/schedule-2.0/src/Entity/User.php
Normal file
@@ -0,0 +1,412 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
||||
* @ORM\Table(name="user",indexes={@ORM\Index(name="username", columns={"username"})})
|
||||
* @UniqueEntity("username", message="Ce nom d'utilisateur existe dèja")
|
||||
*/
|
||||
|
||||
class User implements UserInterface, \Serializable
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="username", type="string", length=255)
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="password", type="string", length=255)
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(name="roles", type="array", length=255)
|
||||
*/
|
||||
private $roles = array();
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="salt", type="string", length=255)
|
||||
*/
|
||||
private $salt = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250, nullable=true)
|
||||
*/
|
||||
private $firstname;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250)
|
||||
*/
|
||||
private $lastname;
|
||||
private $displayname;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=60, nullable=true, options={"default" : 0})
|
||||
*/
|
||||
private $avatar;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250)
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250, nullable=true)
|
||||
*/
|
||||
private $apikey;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Service", inversedBy="users")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private $service;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Event", mappedBy="user", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $events;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Penalty", mappedBy="user", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $penaltys;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Job", inversedBy="users", cascade={"persist"})
|
||||
* @ORM\JoinTable(name="userjob",
|
||||
* joinColumns={@ORM\JoinColumn(name="user", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="job", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
protected $jobs;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Userproject", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
|
||||
*/
|
||||
private $userprojects;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = new ArrayCollection();
|
||||
$this->events = new ArrayCollection();
|
||||
$this->penaltys = new ArrayCollection();
|
||||
$this->jobs = new ArrayCollection();
|
||||
$this->userprojects = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getUsername(): ?string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function getSalt(): ?string
|
||||
{
|
||||
return $this->salt;
|
||||
}
|
||||
|
||||
public function setPassword($password): self
|
||||
{
|
||||
if($password!=$this->password&&$password!=""&&!is_null($password)){
|
||||
$this->salt = uniqid(mt_rand(), true);
|
||||
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($password . $this->salt)) . $this->salt);
|
||||
|
||||
$this->password = $hash;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassword(): ?string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function getRoles(): ?array
|
||||
{
|
||||
return $this->roles;
|
||||
}
|
||||
|
||||
public function eraseCredentials()
|
||||
{
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return serialize(array(
|
||||
$this->id,
|
||||
$this->username,
|
||||
$this->password,
|
||||
$this->salt,
|
||||
));
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
list (
|
||||
$this->id,
|
||||
$this->username,
|
||||
$this->password,
|
||||
$this->salt
|
||||
) = unserialize($serialized, array('allowed_classes' => false));
|
||||
}
|
||||
|
||||
public function getDisplayname()
|
||||
{
|
||||
return $this->firstname." ".$this->lastname;
|
||||
}
|
||||
|
||||
public function setId(int $id): self
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setUsername(string $username): self
|
||||
{
|
||||
$this->username = $username;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function setRoles(array $roles): self
|
||||
{
|
||||
$this->roles = $roles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSalt(string $salt): self
|
||||
{
|
||||
$this->salt = $salt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFirstname(): ?string
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
public function setFirstname(?string $firstname): self
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastname(): ?string
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
public function setLastname(?string $lastname): self
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvatar(): ?string
|
||||
{
|
||||
if($this->avatar)
|
||||
return $this->avatar;
|
||||
else
|
||||
return "noavatar.png";
|
||||
}
|
||||
|
||||
public function setAvatar(?string $avatar): self
|
||||
{
|
||||
$this->avatar = $avatar;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): self
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getService(): ?Service
|
||||
{
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
public function setService(?Service $service): self
|
||||
{
|
||||
$this->service = $service;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Event[]
|
||||
*/
|
||||
public function getEvents(): Collection
|
||||
{
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
public function addEvent(Event $event): self
|
||||
{
|
||||
if (!$this->events->contains($event)) {
|
||||
$this->events[] = $event;
|
||||
$event->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeEvent(Event $event): self
|
||||
{
|
||||
if ($this->events->contains($event)) {
|
||||
$this->events->removeElement($event);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($event->getUser() === $this) {
|
||||
$event->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Penalty[]
|
||||
*/
|
||||
public function getPenaltys(): Collection
|
||||
{
|
||||
return $this->penaltys;
|
||||
}
|
||||
|
||||
public function addPenalty(Penalty $penalty): self
|
||||
{
|
||||
if (!$this->penaltys->contains($penalty)) {
|
||||
$this->penaltys[] = $penalty;
|
||||
$penalty->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePenalty(Penalty $penalty): self
|
||||
{
|
||||
if ($this->penaltys->contains($penalty)) {
|
||||
$this->penaltys->removeElement($penalty);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($penalty->getUser() === $this) {
|
||||
$penalty->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApikey(): ?string
|
||||
{
|
||||
return $this->apikey;
|
||||
}
|
||||
|
||||
public function setApikey(?string $apikey): self
|
||||
{
|
||||
$this->apikey = $apikey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Job[]
|
||||
*/
|
||||
public function getJobs(): Collection
|
||||
{
|
||||
return $this->jobs;
|
||||
}
|
||||
|
||||
public function addJob(Job $job): self
|
||||
{
|
||||
if (!$this->jobs->contains($job)) {
|
||||
$this->jobs[] = $job;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeJob(Job $job): self
|
||||
{
|
||||
if ($this->jobs->contains($job)) {
|
||||
$this->jobs->removeElement($job);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Userproject[]
|
||||
*/
|
||||
public function getUserprojects(): Collection
|
||||
{
|
||||
return $this->userprojects;
|
||||
}
|
||||
|
||||
public function addUserproject(Userproject $userproject): self
|
||||
{
|
||||
if (!$this->userprojects->contains($userproject)) {
|
||||
$this->userprojects[] = $userproject;
|
||||
$userproject->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUserproject(Userproject $userproject): self
|
||||
{
|
||||
if ($this->userprojects->contains($userproject)) {
|
||||
$this->userprojects->removeElement($userproject);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($userproject->getUser() === $this) {
|
||||
$userproject->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
81
src/schedule-2.0/src/Entity/Userproject.php
Normal file
81
src/schedule-2.0/src/Entity/Userproject.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Userproject
|
||||
*
|
||||
* @ORM\Table(name="userproject")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\UserprojectRepository")
|
||||
*/
|
||||
class Userproject
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="userprojects")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Project", inversedBy="userprojects")
|
||||
*/
|
||||
private $project;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Job", inversedBy="userprojects")
|
||||
*/
|
||||
private $job;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProject(): ?Project
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function setProject(?Project $project): self
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getJob(): ?Job
|
||||
{
|
||||
return $this->job;
|
||||
}
|
||||
|
||||
public function setJob(?Job $job): self
|
||||
{
|
||||
$this->job = $job;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
50
src/schedule-2.0/src/Form/BreakdayType.php
Normal file
50
src/schedule-2.0/src/Form/BreakdayType.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class BreakdayType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('start',
|
||||
DateType::class, [
|
||||
"label" =>"Date"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Breakday',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
71
src/schedule-2.0/src/Form/CronType.php
Normal file
71
src/schedule-2.0/src/Form/CronType.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ColorType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Trsteel\CkeditorBundle\Form\Type\CkeditorType;
|
||||
|
||||
class CronType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('submit', SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => array("class" => "btn btn-success")
|
||||
])
|
||||
|
||||
->add('command', TextType::class, [
|
||||
'label' => 'Commande',
|
||||
"disabled" => true,
|
||||
])
|
||||
|
||||
->add('jsonargument', TextType::class, [
|
||||
'label' => 'Argument Commande au format json',
|
||||
"disabled" => true,
|
||||
])
|
||||
|
||||
->add('statut', ChoiceType::class, [
|
||||
'label' => "Statut",
|
||||
'choices' => array("A éxécuter" => "0","Exécution en cours" => "1","OK" => "2","KO" => "3","Désactivé" => "4")
|
||||
])
|
||||
|
||||
->add('repeatcall', IntegerType::class, [
|
||||
'label' => "Nombre d'éxécution en cas d'echec. Si zéro on le répete à l'infini même si OK"
|
||||
])
|
||||
|
||||
->add('repeatinterval', IntegerType::class, [
|
||||
'label' => "Interval en seconde entre deux éxécution"
|
||||
])
|
||||
|
||||
->add('nextexecdate', DatetimeType::class, [
|
||||
'label' => "Prochaine exécution"
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OptionsResolver $resolver
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'App\Entity\Cron',
|
||||
'mode' => 'string'
|
||||
]);
|
||||
}
|
||||
}
|
57
src/schedule-2.0/src/Form/CustomerType.php
Normal file
57
src/schedule-2.0/src/Form/CustomerType.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class CustomerType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success no-print"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('name',
|
||||
TextType::class, [
|
||||
"label" =>"Nom"
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('keypass',
|
||||
TextType::class, [
|
||||
"label" =>"Clé d'accès",
|
||||
"required" => false
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Customer',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
67
src/schedule-2.0/src/Form/JobType.php
Normal file
67
src/schedule-2.0/src/Form/JobType.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class JobType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success no-print"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('name',
|
||||
TextType::class, [
|
||||
"label" =>"Nom"
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('type',
|
||||
ChoiceType::class, [
|
||||
'label' => "Type",
|
||||
"disabled" => ($options["mode"]=="update"),
|
||||
'choices' => array("Fonctionnel" => "Fonctionnel","Organisationnel" => "Organisationnel","Projet" => "Projet")
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('description',
|
||||
CKEditorType::class, [
|
||||
"required" => false,
|
||||
"config" => [
|
||||
'uiColor' => '#ffffff',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Job',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
49
src/schedule-2.0/src/Form/NatureType.php
Normal file
49
src/schedule-2.0/src/Form/NatureType.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class NatureType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('name',
|
||||
TextType::class, [
|
||||
"label" =>"Nom"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Nature',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
104
src/schedule-2.0/src/Form/OfferType.php
Normal file
104
src/schedule-2.0/src/Form/OfferType.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class OfferType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success no-print"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('name',
|
||||
TextType::class, [
|
||||
"label" => "Nom"
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('ref',
|
||||
TextType::class, [
|
||||
"label" => "Référence",
|
||||
"required" => false
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('quantity',
|
||||
NumberType::class, [
|
||||
"label" => "Quantité",
|
||||
//"html5" => true,
|
||||
"scale" => 2
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('pu',
|
||||
NumberType::class, [
|
||||
"label" => "Prix Unitaire",
|
||||
//"html5" => true,
|
||||
"scale" => 2
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add("active",
|
||||
ChoiceType::class,[
|
||||
"label" => "Actif",
|
||||
"choices" => ["Oui"=>true,"Non"=>false]
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('project',
|
||||
Select2EntityType::class, [
|
||||
"label" => "Projet",
|
||||
"disabled" => false,
|
||||
"required" => true,
|
||||
"multiple" => false,
|
||||
"remote_route" => "app_project_select",
|
||||
"class" => "App:Project",
|
||||
"primary_key" => "id",
|
||||
"text_property" => "displayname",
|
||||
"minimum_input_length" => 0,
|
||||
"page_limit" => 10,
|
||||
"allow_clear" => true,
|
||||
"delay" => 250,
|
||||
"cache" => false,
|
||||
"cache_timeout" => 60000,
|
||||
"language" => "fr",
|
||||
"placeholder" => "Selectionner un Projet",
|
||||
//"attr" => ["class" => "form-control", "style" => "margin-bottom:15px"]
|
||||
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Offer',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
73
src/schedule-2.0/src/Form/ProjectType.php
Normal file
73
src/schedule-2.0/src/Form/ProjectType.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class ProjectType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success no-print"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('name',
|
||||
TextType::class, [
|
||||
"label" =>"Nom"
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add("active",
|
||||
ChoiceType::class,[
|
||||
"label" => "Actif",
|
||||
"choices" => ["Oui"=>true,"Non"=>false]
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('customer',
|
||||
EntityType::class, [
|
||||
"class" => "App:Customer",
|
||||
"label" => "Client",
|
||||
"choice_label" => "name",
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('service',
|
||||
EntityType::class, [
|
||||
"class" => "App:Service",
|
||||
"label" => "Service",
|
||||
"choice_label" => "name",
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Project',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
58
src/schedule-2.0/src/Form/ServiceType.php
Normal file
58
src/schedule-2.0/src/Form/ServiceType.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class ServiceType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success no-print"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('name',
|
||||
TextType::class, [
|
||||
"label" =>"Nom"
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('description',
|
||||
CKEditorType::class, [
|
||||
"required" => false,
|
||||
"config" => [
|
||||
'uiColor' => '#ffffff',
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Service',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
96
src/schedule-2.0/src/Form/TaskType.php
Normal file
96
src/schedule-2.0/src/Form/TaskType.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class TaskType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success no-print"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('name',
|
||||
TextType::class, [
|
||||
"label" => "Nom"
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('quantity',
|
||||
NumberType::class, [
|
||||
"label" => "Estimation",
|
||||
//"html5" => true,
|
||||
"scale" => 2,
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('nature',
|
||||
EntityType::class, [
|
||||
"class" => "App:Nature",
|
||||
"label" => "Nature",
|
||||
"choice_label" => "name",
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('color',
|
||||
TextType::class, [
|
||||
"label" => "Couleur",
|
||||
"attr" => array("class" => "pick-a-color")
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('project',
|
||||
Select2EntityType::class, [
|
||||
"label" => "Projet",
|
||||
"disabled" => false,
|
||||
"required" => true,
|
||||
"multiple" => false,
|
||||
"remote_route" => "app_project_select",
|
||||
"class" => "App:Project",
|
||||
"primary_key" => "id",
|
||||
"text_property" => "displayname",
|
||||
"minimum_input_length" => 0,
|
||||
"page_limit" => 10,
|
||||
"allow_clear" => true,
|
||||
"delay" => 250,
|
||||
"cache" => false,
|
||||
"cache_timeout" => 60000,
|
||||
"language" => "fr",
|
||||
"placeholder" => "Selectionner un Projet",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Task',
|
||||
'mode' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
130
src/schedule-2.0/src/Form/UserType.php
Normal file
130
src/schedule-2.0/src/Form/UserType.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class UserType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success no-print"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('username',
|
||||
TextType::class, [
|
||||
"label" =>"Login",
|
||||
"disabled" => ($options["mode"]=="submit"?false:true),
|
||||
"attr" => ["autocomplete" => "off"],
|
||||
]
|
||||
);
|
||||
|
||||
if($options["appAuth"]=="MYSQL"&&$options["mode"]!="profil") {
|
||||
$builder->add('password',
|
||||
RepeatedType::class, [
|
||||
"type" => PasswordType::class,
|
||||
"required" => ($options["mode"]=="submit"?true:false),
|
||||
"first_options" => ["label" => "Mot de Passe", "attr" => ["class" => " no-print", "autocomplete" => "new-password"]],
|
||||
"second_options" => ["label" => "Confirmer Mot de Passe", "attr" => ["class" => "no-print"]],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if($options["mode"]!="profil") {
|
||||
$choices=[];
|
||||
$choices['Administrateur']='ROLE_ADMIN';
|
||||
$choices['Validateur']='ROLE_VALIDATOR';
|
||||
$choices['Master']='ROLE_MASTER';
|
||||
$choices['Intervenant']='ROLE_USER';
|
||||
$choices['Invité']='ROLE_VISITOR';
|
||||
|
||||
$builder->add('roles',
|
||||
ChoiceType::class, [
|
||||
'choices' => $choices,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$builder->add('lastname',
|
||||
TextType::class, [
|
||||
"label" =>"Nom",
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('firstname',
|
||||
TextType::class, [
|
||||
"label" =>"Prénom",
|
||||
"required" => false ]
|
||||
);
|
||||
|
||||
$builder->add('email',
|
||||
EmailType::class, [
|
||||
"label" =>"Email",
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('service',
|
||||
EntityType::class, [
|
||||
"class" => "App:Service",
|
||||
"label" => "Service",
|
||||
"required" => false,
|
||||
"choice_label" => "name",
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('jobs',
|
||||
Select2EntityType::class, [
|
||||
"label" => "Métiers",
|
||||
"disabled" => false,
|
||||
"required" => false,
|
||||
"multiple" => true,
|
||||
"remote_route" => "app_job_select",
|
||||
"class" => "App:Job",
|
||||
"primary_key" => "id",
|
||||
"text_property" => "name",
|
||||
"minimum_input_length" => 0,
|
||||
"page_limit" => 100,
|
||||
"allow_clear" => true,
|
||||
"delay" => 250,
|
||||
"cache" => false,
|
||||
"cache_timeout" => 60000,
|
||||
"language" => "fr",
|
||||
"placeholder" => "Selectionner des Métiers",
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('avatar',HiddenType::class, array("empty_data" => "noavatar.png"));
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\User',
|
||||
'mode' => 'string',
|
||||
'appAuth' => 'string',
|
||||
));
|
||||
}
|
||||
}
|
54
src/schedule-2.0/src/Kernel.php
Normal file
54
src/schedule-2.0/src/Kernel.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
|
||||
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
$contents = require $this->getProjectDir().'/config/bundles.php';
|
||||
foreach ($contents as $class => $envs) {
|
||||
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
|
||||
yield new $class();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getProjectDir(): string
|
||||
{
|
||||
return \dirname(__DIR__);
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||
{
|
||||
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
|
||||
$container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug);
|
||||
$container->setParameter('container.dumper.inline_factories', true);
|
||||
$confDir = $this->getProjectDir().'/config';
|
||||
|
||||
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
|
||||
}
|
||||
|
||||
protected function configureRoutes(RouteCollectionBuilder $routes): void
|
||||
{
|
||||
$confDir = $this->getProjectDir().'/config';
|
||||
|
||||
$routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
|
||||
}
|
||||
}
|
1
src/schedule-2.0/src/Migrations/.gitignore
vendored
Normal file
1
src/schedule-2.0/src/Migrations/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.php
|
0
src/schedule-2.0/src/Repository/.gitignore
vendored
Normal file
0
src/schedule-2.0/src/Repository/.gitignore
vendored
Normal file
15
src/schedule-2.0/src/Repository/BreakdayRepository.php
Normal file
15
src/schedule-2.0/src/Repository/BreakdayRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Breakday;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class BreakdayRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Breakday::class);
|
||||
}
|
||||
}
|
35
src/schedule-2.0/src/Repository/CronRepository.php
Normal file
35
src/schedule-2.0/src/Repository/CronRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Cron;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class CronRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Cron::class);
|
||||
}
|
||||
|
||||
public function toExec()
|
||||
{
|
||||
// Les commandes à executer
|
||||
// = statut = 0 (à executer)
|
||||
// = statut = 2 (OK) et derniere execution + interval > now et nombre d'appel = 0
|
||||
// = statut = 3 (KO) et derniere execution + interval > now et nombre d'appel = 0
|
||||
// = statut = 3 (KO) et nombre d'execution < nombre d'appel
|
||||
|
||||
|
||||
$now=new \DateTime();
|
||||
|
||||
$qb = $this->createQueryBuilder('cron')
|
||||
->Where('cron.statut=0')
|
||||
->orWhere('cron.statut=2 AND cron.nextexecdate<:now AND cron.repeatcall=0')
|
||||
->orWhere('cron.statut=3 AND cron.nextexecdate<:now AND cron.repeatcall=0')
|
||||
->orWhere('cron.statut=3 AND cron.nextexecdate<:now AND cron.repeatcall>cron.repeatexec');
|
||||
|
||||
return $qb->getQuery()->setParameter('now',$now->format("Y-m-d H:i:s"))->getResult();
|
||||
}
|
||||
}
|
15
src/schedule-2.0/src/Repository/CustomerRepository.php
Normal file
15
src/schedule-2.0/src/Repository/CustomerRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class CustomerRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Customer::class);
|
||||
}
|
||||
}
|
15
src/schedule-2.0/src/Repository/EventRepository.php
Normal file
15
src/schedule-2.0/src/Repository/EventRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Event;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class EventRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Event::class);
|
||||
}
|
||||
}
|
15
src/schedule-2.0/src/Repository/JobRepository.php
Normal file
15
src/schedule-2.0/src/Repository/JobRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Job;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class JobRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Job::class);
|
||||
}
|
||||
}
|
15
src/schedule-2.0/src/Repository/NatureRepository.php
Normal file
15
src/schedule-2.0/src/Repository/NatureRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Nature;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class NatureRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Nature::class);
|
||||
}
|
||||
}
|
15
src/schedule-2.0/src/Repository/OfferRepository.php
Normal file
15
src/schedule-2.0/src/Repository/OfferRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Offer;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class OfferRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Offer::class);
|
||||
}
|
||||
}
|
15
src/schedule-2.0/src/Repository/PenaltyRepository.php
Normal file
15
src/schedule-2.0/src/Repository/PenaltyRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Penalty;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class PenaltyRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Penalty::class);
|
||||
}
|
||||
}
|
94
src/schedule-2.0/src/Repository/ProjectRepository.php
Normal file
94
src/schedule-2.0/src/Repository/ProjectRepository.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Project;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class ProjectRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Project::class);
|
||||
}
|
||||
|
||||
public function sumDuration($id,$validate) {
|
||||
$hors=0;
|
||||
if($validate) {
|
||||
$qb = $this->createQueryBuilder('project')
|
||||
->select('SUM(task.validate) as somme')
|
||||
->from('App:Task','task')
|
||||
->Where('project.id=:id')
|
||||
->andWhere('task.project=project')
|
||||
->setParameter('id',$id);
|
||||
|
||||
$result=$qb->getQuery()->getOneOrNullResult();
|
||||
$hors=($result["somme"]?$result["somme"]:0);
|
||||
|
||||
$qb = $this->createQueryBuilder('project')
|
||||
->select('SUM(offer.validate) as somme')
|
||||
->from('App:Offer','offer')
|
||||
->Where('project.id=:id')
|
||||
->andWhere('offer.project=project')
|
||||
->setParameter('id',$id);
|
||||
|
||||
$result=$qb->getQuery()->getOneOrNullResult();
|
||||
$hors=($result["somme"]?$result["somme"]:0);
|
||||
}
|
||||
|
||||
$qb = $this->createQueryBuilder('project')
|
||||
->select('SUM(event.duration) as somme')
|
||||
->from('App:Task','task')
|
||||
->from('App:Event','event')
|
||||
->Where('project.id=:id')
|
||||
->andWhere('task.project=project')
|
||||
->andWhere('event.task=task')
|
||||
->andWhere('event.validate=:validate')
|
||||
->setParameter('id',$id)
|
||||
->setParameter('validate',$validate);
|
||||
$result=$qb->getQuery()->getOneOrNullResult();
|
||||
$event=($result["somme"]?$result["somme"]:0);
|
||||
|
||||
$qb = $this->createQueryBuilder('project')
|
||||
->select('SUM(penalty.duration) as somme')
|
||||
->from('App:Task','task')
|
||||
->from('App:Penalty','penalty')
|
||||
->Where('project.id=:id')
|
||||
->andWhere('task.project=project')
|
||||
->andWhere('penalty.task=task')
|
||||
->andWhere('penalty.validate=:validate')
|
||||
->setParameter('id',$id)
|
||||
->setParameter('validate',$validate);
|
||||
$result=$qb->getQuery()->getOneOrNullResult();
|
||||
$penalty=($result["somme"]?$result["somme"]:0);
|
||||
|
||||
return ($hors+$event+$penalty);
|
||||
}
|
||||
|
||||
public function sumProposed($id) {
|
||||
$qb = $this->createQueryBuilder('project')
|
||||
->select('SUM(offer.quantity) as somme')
|
||||
->from('App:Offer','offer')
|
||||
->Where('project.id=:id')
|
||||
->andWhere('offer.project=project')
|
||||
->setParameter('id',$id);
|
||||
$result=$qb->getQuery()->getOneOrNullResult();
|
||||
|
||||
$proposed=($result["somme"]?$result["somme"]:0);
|
||||
return $proposed;
|
||||
}
|
||||
|
||||
public function sumEstimate($id) {
|
||||
$qb = $this->createQueryBuilder('project')
|
||||
->select('SUM(task.quantity) as somme1, SUM(task.validate) as somme2 ')
|
||||
->from('App:Task','task')
|
||||
->Where('project.id=:id')
|
||||
->andWhere('task.project=project')
|
||||
->setParameter('id',$id);
|
||||
$result=$qb->getQuery()->getOneOrNullResult();
|
||||
|
||||
$estimate=($result["somme1"]?$result["somme1"]:0)+($result["somme2"]?$result["somme2"]:0);
|
||||
return $estimate;
|
||||
}
|
||||
}
|
57
src/schedule-2.0/src/Repository/ServiceRepository.php
Normal file
57
src/schedule-2.0/src/Repository/ServiceRepository.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Service;
|
||||
use App\Entity\Project;
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class ServiceRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Service::class);
|
||||
}
|
||||
|
||||
|
||||
public function findAllProjectActive($activeproject,$idservice) {
|
||||
$qb = $this->createQueryBuilder('service')
|
||||
->from('App:Project','project')
|
||||
->Where('project.active=:activeproject')
|
||||
->andWhere('project.service=service');
|
||||
|
||||
if($idservice!="all")
|
||||
$qb->andWhere("service.id=:id")->setParameter('id',$idservice);
|
||||
|
||||
return $qb->getQuery()->setParameter('activeproject',$activeproject)->getResult();
|
||||
}
|
||||
|
||||
public function findAllOfferActive($activeproject,$activeoffer,$idservice) {
|
||||
$qb = $this->createQueryBuilder('service')
|
||||
->from('App:Project','project')
|
||||
->from('App:Offer','offer')
|
||||
->Where('offer.active=:activeoffer')
|
||||
->andWhere('project.active=:activeproject')
|
||||
->andWhere('project.service=service')
|
||||
->andWhere('offer.project=project');
|
||||
|
||||
if($idservice!="all")
|
||||
$qb->andWhere("service.id=:id")->setParameter('id',$idservice);
|
||||
|
||||
return $qb->getQuery()->setParameter('activeproject',$activeproject)->setParameter('activeoffer',$activeoffer)->getResult();
|
||||
}
|
||||
|
||||
public function findAllTaskActive($activeproject,$idservice) {
|
||||
$qb = $this->createQueryBuilder('service')
|
||||
->from('App:Project','project')
|
||||
->Where('project.active=:activeproject')
|
||||
->andWhere('project.service=service');
|
||||
|
||||
if($idservice!="all")
|
||||
$qb->andWhere("service.id=:id")->setParameter('id',$idservice);
|
||||
|
||||
return $qb->getQuery()->setParameter('activeproject',$activeproject)->getResult();
|
||||
}
|
||||
}
|
15
src/schedule-2.0/src/Repository/TaskRepository.php
Normal file
15
src/schedule-2.0/src/Repository/TaskRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Task;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class TaskRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Task::class);
|
||||
}
|
||||
}
|
20
src/schedule-2.0/src/Repository/UserRepository.php
Normal file
20
src/schedule-2.0/src/Repository/UserRepository.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
class UserRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
public function findAll()
|
||||
{
|
||||
return $this->findBy(array(), array('firstname' => 'ASC', 'lastname' => 'ASC'));
|
||||
}
|
||||
}
|
50
src/schedule-2.0/src/Repository/UserprojectRepository.php
Normal file
50
src/schedule-2.0/src/Repository/UserprojectRepository.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Userproject;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Userproject|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Userproject|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Userproject[] findAll()
|
||||
* @method Userproject[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class UserprojectRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Userproject::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Userproject[] Returns an array of Userproject objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->andWhere('u.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('u.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Userproject
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->andWhere('u.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
27
src/schedule-2.0/src/Service/passwordEncoder.php
Normal file
27
src/schedule-2.0/src/Service/passwordEncoder.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
||||
|
||||
class passwordEncoder implements PasswordEncoderInterface
|
||||
{
|
||||
|
||||
public function encodePassword($raw, $salt)
|
||||
{
|
||||
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($raw . $salt)) . $salt);
|
||||
return $hash;
|
||||
}
|
||||
|
||||
public function isPasswordValid($encoded, $raw, $salt)
|
||||
{
|
||||
return $encoded === $this->encodePassword($raw, $salt);
|
||||
}
|
||||
|
||||
public function needsRehash(string $encoded): bool
|
||||
{
|
||||
// check whether the current password is hash using an outdated encoder
|
||||
$hashIsOutdated = false;
|
||||
return $hashIsOutdated;
|
||||
}
|
||||
|
||||
}
|
125
src/schedule-2.0/src/Service/sessionListener.php
Normal file
125
src/schedule-2.0/src/Service/sessionListener.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
|
||||
class sessionListener {
|
||||
protected $container;
|
||||
protected $em;
|
||||
|
||||
public function __construct($container, EntityManager $em, TokenStorageInterface $token_storage)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->em = $em;
|
||||
$this->token_storage = $token_storage;
|
||||
}
|
||||
|
||||
public function haveRole($roles,$tohave) {
|
||||
$haverole=false;
|
||||
if($roles=="") {
|
||||
if(empty($tohave)) $haverole=true;
|
||||
}
|
||||
else {
|
||||
foreach($roles as $role) {
|
||||
if(in_array($role,$tohave))
|
||||
$haverole=true;
|
||||
}
|
||||
}
|
||||
|
||||
return $haverole;
|
||||
}
|
||||
|
||||
public function onDomainParse(Event $event) {
|
||||
$session = new Session();
|
||||
|
||||
// Utilisateur en cours
|
||||
$curentuserid=0;
|
||||
$token = $this->token_storage->getToken();
|
||||
if(!$token) return;
|
||||
$curentuser=$token->getUser();
|
||||
|
||||
// Roles actif
|
||||
if($curentuser=="anon.") $roles=[];
|
||||
else $roles=$curentuser->getRoles();
|
||||
|
||||
$regen=false;
|
||||
if (!$session->get('isuser') && $curentuser!="anon.") {
|
||||
$regen=true;
|
||||
$session->set('isuser',true);
|
||||
}
|
||||
|
||||
if ($session->get('isuser') && $curentuser=="anon.") {
|
||||
$regen=true;
|
||||
$session->set('isuser',false);
|
||||
}
|
||||
|
||||
if(!$session->get('nbmonth')) $regen=true;
|
||||
|
||||
|
||||
// Initialisation de la session
|
||||
if($regen) {
|
||||
$session->set('activeproject',true);
|
||||
$session->set('activeoffer',true);
|
||||
$session->set('activeholiday',true);
|
||||
$session->set('nbmonth',3);
|
||||
|
||||
if($curentuser!="anon.") {
|
||||
if(in_array("ROLE_USER",$roles))
|
||||
$session->set('iduser',$curentuser->getId());
|
||||
else
|
||||
$session->set('iduser',"all");
|
||||
|
||||
$session->set('idproject',"all");
|
||||
$session->set('idservice',"all");
|
||||
}
|
||||
else {
|
||||
$session->set('iduser',"all");
|
||||
$session->set('idproject',"all");
|
||||
$session->set('idservice',"all");
|
||||
}
|
||||
|
||||
$tbusers=[];
|
||||
$users=$this->em->getRepository('App:User')->findAll();
|
||||
foreach($users as $user) {
|
||||
if(in_array("ROLE_USER",$user->getRoles())) {
|
||||
$tmp=[
|
||||
"id"=>$user->getId(),
|
||||
"displayname"=>$user->getDisplayname()
|
||||
];
|
||||
array_push($tbusers,$tmp);
|
||||
}
|
||||
}
|
||||
$session->set('users',$tbusers);
|
||||
|
||||
$tbprojects=[];
|
||||
$projects=$this->em->getRepository('App:Project')->findBy(["active"=>true]);
|
||||
foreach($projects as $project) {
|
||||
$tmp=[
|
||||
"id"=>$project->getId(),
|
||||
"displayname"=>$project->getDisplayname()
|
||||
];
|
||||
array_push($tbprojects,$tmp);
|
||||
}
|
||||
$session->set('projects',$tbprojects);
|
||||
|
||||
$tbservices=[];
|
||||
$services=$this->em->getRepository('App:Service')->findAll();
|
||||
foreach($services as $service) {
|
||||
$tmp=[
|
||||
"id"=>$service->getId(),
|
||||
"name"=>$service->getName()
|
||||
];
|
||||
array_push($tbservices,$tmp);
|
||||
}
|
||||
$session->set('services',$tbservices);
|
||||
}
|
||||
}
|
||||
}
|
181
src/schedule-2.0/src/Service/uploadListener.php
Normal file
181
src/schedule-2.0/src/Service/uploadListener.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Oneup\UploaderBundle\Event\PostPersistEvent;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
|
||||
|
||||
class uploadListener
|
||||
{
|
||||
private $em;
|
||||
private $session;
|
||||
private $token;
|
||||
private $container;
|
||||
|
||||
public function __construct(EntityManager $em, TokenStorageInterface $token_storage, Session $session, Container $container)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->session = $session;
|
||||
$this->token = $token_storage;
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
protected function getHeight($image) {
|
||||
$size = getimagesize($image);
|
||||
$height = $size[1];
|
||||
return $height;
|
||||
}
|
||||
|
||||
// Cacul de la largeur
|
||||
protected function getWidth($image) {
|
||||
$size = getimagesize($image);
|
||||
$width = $size[0];
|
||||
return $width;
|
||||
}
|
||||
|
||||
protected function resizeImage($image,$width,$height,$scale) {
|
||||
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
|
||||
$imageType = image_type_to_mime_type($imageType);
|
||||
$newImageWidth = ceil($width * $scale);
|
||||
$newImageHeight = ceil($height * $scale);
|
||||
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
$source=imagecreatefromgif($image);
|
||||
break;
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
$source=imagecreatefromjpeg($image);
|
||||
break;
|
||||
case "image/png":
|
||||
case "image/x-png":
|
||||
$source=imagecreatefrompng($image);
|
||||
break;
|
||||
}
|
||||
|
||||
$newImage = imagecreatetruecolor( $newImageWidth, $newImageHeight );
|
||||
imagealphablending( $newImage, false );
|
||||
imagesavealpha( $newImage, true );
|
||||
imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
|
||||
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
imagegif($newImage,$image);
|
||||
break;
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
imagejpeg($newImage,$image,90);
|
||||
break;
|
||||
case "image/png":
|
||||
case "image/x-png":
|
||||
imagepng($newImage,$image);
|
||||
break;
|
||||
}
|
||||
|
||||
chmod($image, 0640);
|
||||
return $image;
|
||||
}
|
||||
|
||||
public function onUpload(PostPersistEvent $event)
|
||||
{
|
||||
$type=$event->getType();
|
||||
switch($type) {
|
||||
case "avatar":
|
||||
$file=$event->getFile();
|
||||
$filename=$file->getFilename();
|
||||
$this->session->set('uploadavatar', $filename);
|
||||
break;
|
||||
case "file":
|
||||
$file=$event->getFile();
|
||||
$filename=$file->getFilename();
|
||||
$pathname=$file->getPath();
|
||||
|
||||
// Déplacer le fichier dans la cible
|
||||
$request = $event->getRequest();
|
||||
$directory = $request->get('directory');
|
||||
$fs = new Filesystem();
|
||||
$fgexit=$fs->exists($pathname."/".$directory."/".$filename);
|
||||
$file->move($pathname."/".$directory, $filename);
|
||||
|
||||
// Création d'un thumb dans le cas d'un fichier de type imapge
|
||||
if (in_array(strtolower($file->GetExtension()), array('jpg', 'jpeg', 'jpe', 'png', 'gif', 'bmp'))) {
|
||||
$fs = new Filesystem();
|
||||
$fs->copy($pathname."/".$directory."/".$filename,$pathname."/".$directory."/thumb/".$filename);
|
||||
$max_width=350;
|
||||
$width = $this->getWidth($pathname."/".$directory."/thumb/".$filename);
|
||||
$height = $this->getHeight($pathname."/".$directory."/thumb/".$filename);
|
||||
$scale = $max_width/$width;
|
||||
$this->resizeImage($pathname."/".$directory."/thumb/".$filename,$width,$height,$scale);
|
||||
}
|
||||
|
||||
|
||||
if (in_array(strtolower($file->GetExtension()), array('pdf'))) {
|
||||
$im = new \Imagick();
|
||||
$im->setResolution(350, 350);
|
||||
$im->readImage($pathname."/".$directory."/".$filename."[0]");
|
||||
$im->setImageBackgroundColor('#ffffff');
|
||||
$im = $im->flattenImages();
|
||||
$im->setImageFormat('jpeg');
|
||||
$fs->mkdir($pathname."/".$directory."/thumb");
|
||||
$im->writeImage($pathname."/".$directory."/thumb/".$filename.".jpg");
|
||||
$fs->rename($pathname."/".$directory."/thumb/".$filename.".jpg", $pathname."/".$directory."/thumb/".$filename);
|
||||
}
|
||||
|
||||
if (strpos($directory, 'widget') === 0) {
|
||||
$tmp=explode("-",$directory);
|
||||
$widgetid=$tmp[1];
|
||||
$widget=$this->em->getRepository("CadolesPortalBundle:Pagewidget")->find($widgetid);
|
||||
if($widget) {
|
||||
foreach($widget->getPage()->getGroups() as $group) {
|
||||
if($group->getFgcanshare()) {
|
||||
if($fgexit) $message="Modification fichier<br>".$filename;
|
||||
else $message="Création fichier<br>".$filename;
|
||||
|
||||
$usergroup=$this->em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$group,"user"=>$this->token->getToken()->getUser()]);
|
||||
if($usergroup) {
|
||||
$key=$usergroup->getKeyvalue();
|
||||
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->token->getToken()->getUser()->getId(),$group->getId(),$message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = $event->getResponse();
|
||||
$response['file'] = $filename;
|
||||
break;
|
||||
|
||||
case "blogarticle":
|
||||
$file=$event->getFile();
|
||||
$filename=$file->getFilename();
|
||||
$pathname=$file->getPath();
|
||||
|
||||
// Creation d'un thumb
|
||||
$fs = new Filesystem();
|
||||
$fs->copy($pathname."/".$filename,$pathname."/thumb-".$filename);
|
||||
$max_width=350;
|
||||
$width = $this->getWidth($pathname."/thumb-".$filename);
|
||||
$height = $this->getHeight($pathname."/thumb-".$filename);
|
||||
$scale = $max_width/$width;
|
||||
$this->resizeImage($pathname."/thumb-".$filename,$width,$height,$scale);
|
||||
|
||||
$response = $event->getResponse();
|
||||
$response['file'] = $filename;
|
||||
break;
|
||||
|
||||
default:
|
||||
$file=$event->getFile();
|
||||
$filename=$file->getFilename();
|
||||
$response = $event->getResponse();
|
||||
$response['file'] = $filename;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user