svg
This commit is contained in:
53
.php-cs-fixer.dist.php
Normal file
53
.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$finder = PhpCsFixer\Finder::create()
|
||||||
|
->in(__DIR__)
|
||||||
|
->exclude([
|
||||||
|
'vendor',
|
||||||
|
'var',
|
||||||
|
'web',
|
||||||
|
'app/DoctrineMigrations',
|
||||||
|
'bin',
|
||||||
|
'doc',
|
||||||
|
])
|
||||||
|
->name('*.php')
|
||||||
|
;
|
||||||
|
|
||||||
|
// TODO: Définir les règles de style communes
|
||||||
|
// spécifiques au projet
|
||||||
|
return (new PhpCsFixer\Config())
|
||||||
|
->setRules([
|
||||||
|
'@Symfony' => true,
|
||||||
|
'concat_space' => ['spacing' => 'none'],
|
||||||
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
'combine_consecutive_issets' => true,
|
||||||
|
'explicit_indirect_variable' => true,
|
||||||
|
'no_useless_return' => true,
|
||||||
|
'ordered_imports' => true,
|
||||||
|
'no_unused_imports' => true,
|
||||||
|
'no_spaces_after_function_name' => true,
|
||||||
|
'no_spaces_inside_parenthesis' => true,
|
||||||
|
'ternary_operator_spaces' => true,
|
||||||
|
'class_definition' => ['single_line' => true],
|
||||||
|
'whitespace_after_comma_in_array' => true,
|
||||||
|
|
||||||
|
// phpdoc
|
||||||
|
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
|
||||||
|
'phpdoc_order' => true,
|
||||||
|
'phpdoc_types_order' => [
|
||||||
|
'null_adjustment' => 'always_last',
|
||||||
|
'sort_algorithm' => 'alpha',
|
||||||
|
],
|
||||||
|
'phpdoc_no_empty_return' => false,
|
||||||
|
'phpdoc_summary' => false,
|
||||||
|
'general_phpdoc_annotation_remove' => [
|
||||||
|
'annotations' => [
|
||||||
|
'expectedExceptionMessageRegExp',
|
||||||
|
'expectedException',
|
||||||
|
'expectedExceptionMessage',
|
||||||
|
'author',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->setFinder($finder)
|
||||||
|
;
|
@@ -2,50 +2,47 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
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\Service\icsService;
|
use App\Service\icsService;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class ApiController extends AbstractController
|
class ApiController extends AbstractController
|
||||||
{
|
{
|
||||||
public function api($key,Request $request)
|
public function api($key): Response
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$user=$em->getRepository("App:User")->findBy(["apikey"=>$key]);
|
$user = $em->getRepository('App:User')->findBy(['apikey' => $key]);
|
||||||
if(!$user) {
|
if (!$user) {
|
||||||
return new Response("Accès refusé", 403);
|
return new Response('Accès refusé', 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ics = new icsService();
|
$ics = new icsService();
|
||||||
$ics->debug(false);
|
$ics->debug(false);
|
||||||
|
|
||||||
$content=$ics->writeheader();
|
$content = $ics->writeheader();
|
||||||
|
|
||||||
$events=$em->getRepository("App:Event")->findBy(["user"=>$user]);
|
$events = $em->getRepository('App:Event')->findBy(['user' => $user]);
|
||||||
foreach($events as $event) {
|
foreach ($events as $event) {
|
||||||
$task=$event->getTask();
|
$task = $event->getTask();
|
||||||
$project=$task->getProject();
|
$project = $task->getProject();
|
||||||
$customer=$project->getCustomer();
|
$customer = $project->getCustomer();
|
||||||
|
|
||||||
$ics->set(
|
$ics->set(
|
||||||
[
|
[
|
||||||
'allday' => $event->getAllday(),
|
'allday' => $event->getAllday(),
|
||||||
'description' => $event->getDescription(),
|
'description' => $event->getDescription(),
|
||||||
'dtstart' => $event->getStart()->format("Y-m-d H:i:s"),
|
'dtstart' => $event->getStart()->format('Y-m-d H:i:s'),
|
||||||
'dtend' => $event->getEnd()->format("Y-m-d H:i:s"),
|
'dtend' => $event->getEnd()->format('Y-m-d H:i:s'),
|
||||||
'summary' => $customer->getName()."-".$project->getName()."-".$task->getName(),
|
'summary' => $customer->getName().'-'.$project->getName().'-'.$task->getName(),
|
||||||
'uid' => "schedule".$event->getId()
|
'uid' => 'schedule'.$event->getId(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$content.=$ics->writeevent();
|
$content .= $ics->writeevent();
|
||||||
}
|
}
|
||||||
|
|
||||||
$content.=$ics->writefooter();
|
$content .= $ics->writefooter();
|
||||||
|
|
||||||
return new Response($content);
|
return new Response($content);
|
||||||
}
|
}
|
||||||
|
@@ -2,169 +2,101 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Breakday;
|
||||||
|
use App\Form\BreakdayType;
|
||||||
|
use App\Repository\BreakdayRepository;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
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
|
class BreakdayController extends AbstractController
|
||||||
{
|
{
|
||||||
private $data = "breakday";
|
private EntityManagerInterface $em;
|
||||||
private $route = "app_breakday";
|
private BreakdayRepository $breakdayRepository;
|
||||||
private $render = "Breakday/";
|
|
||||||
private $entity = "App:Breakday";
|
|
||||||
|
|
||||||
private $knpSnappy;
|
public function __construct(EntityManagerInterface $em, BreakdayRepository $breakdayRepository)
|
||||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
|
||||||
|
|
||||||
public function list(Request $request)
|
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$this->em = $em;
|
||||||
$datas = $em->getRepository($this->entity)->findAll();
|
$this->breakdayRepository = $breakdayRepository;
|
||||||
|
|
||||||
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',[
|
public function list()
|
||||||
$this->data."s" => $datas,
|
{
|
||||||
"useheader" => true,
|
$breakdays = $this->breakdayRepository->findAll();
|
||||||
"usesidebar" => true,
|
|
||||||
|
return $this->render('Breakday/list.html.twig', [
|
||||||
|
'breakdays' => $breakdays,
|
||||||
|
'useheader' => true,
|
||||||
|
'usesidebar' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function submit(Request $request)
|
public function submit(Request $request)
|
||||||
{
|
{
|
||||||
// Initialisation de l'enregistrement
|
$breakday = new Breakday();
|
||||||
$em = $this->getDoctrine()->getManager();
|
$form = $this->createForm(BreakdayType::class, $breakday, ['mode' => 'submit']);
|
||||||
$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);
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
// Sur erreur
|
$end = clone $breakday->getStart();
|
||||||
$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'));
|
$end->add(new \DateInterval('P1D'));
|
||||||
$data->setEnd($end);
|
$breakday->setEnd($end);
|
||||||
$em->persist($data);
|
$this->em->persist($breakday);
|
||||||
$em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
// Retour à la liste
|
return $this->redirectToRoute('app_breakday');
|
||||||
return $this->redirectToRoute($this->route);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage du formulaire
|
return $this->render('Breakday/edit.html.twig', [
|
||||||
return $this->render($this->render.'edit.html.twig', [
|
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
'breakday' => $breakday,
|
||||||
'mode' => 'submit',
|
'mode' => 'submit',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id,Request $request)
|
public function update(int $id, Request $request)
|
||||||
{
|
{
|
||||||
// Initialisation de l'enregistrement
|
$breakday = $this->breakdayRepository->find($id);
|
||||||
$em = $this->getDoctrine()->getManager();
|
if (!$breakday) {
|
||||||
$data=$em->getRepository($this->entity)->find($id);
|
throw new NotFoundHttpException('La ressource demandée est introuvable.');
|
||||||
|
}
|
||||||
// Création du formulaire
|
$form = $this->createForm(BreakdayType::class, $breakday, ['mode' => 'update']);
|
||||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
|
||||||
|
|
||||||
// Récupération des data du formulaire
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
// Sur erreur
|
$breakday = $form->getData();
|
||||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
$end = clone $breakday->getStart();
|
||||||
|
|
||||||
// Sur validation
|
|
||||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
|
||||||
$data = $form->getData();
|
|
||||||
$end = clone $data->getStart();
|
|
||||||
$end->add(new \DateInterval('P1D'));
|
$end->add(new \DateInterval('P1D'));
|
||||||
$data->setEnd($end);
|
$breakday->setEnd($end);
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
$em->persist($data);
|
return $this->redirectToRoute('app_breakday');
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
// Retour à la liste
|
|
||||||
return $this->redirectToRoute($this->route);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage du formulaire
|
return $this->render('Breakday/edit.html.twig', [
|
||||||
return $this->render($this->render.'edit.html.twig', [
|
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
'breakday' => $breakday,
|
||||||
'mode' => 'update',
|
'mode' => 'update',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id,Request $request)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
// Initialisation de l'enregistrement
|
$breakday = $this->breakdayRepository->find($id);
|
||||||
$em = $this->getDoctrine()->getManager();
|
if (!$breakday) {
|
||||||
$data=$em->getRepository($this->entity)->find($id);
|
throw new NotFoundHttpException('La ressource demandée est introuvable.');
|
||||||
|
}
|
||||||
|
|
||||||
// Controle avant suppression
|
|
||||||
$error=false;
|
|
||||||
if($error)
|
|
||||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
|
||||||
else {
|
|
||||||
try {
|
try {
|
||||||
$em->remove($data);
|
$this->em->remove($breakday);
|
||||||
$em->flush();
|
$this->em->flush();
|
||||||
}
|
} catch (\Exception $e) {
|
||||||
catch(\Doctrine\DBAL\DBALException $e) {
|
$this->addflash('error', $e->getMessage());
|
||||||
// Création du formulaire
|
|
||||||
$this->get('session')->getFlashBag()->add('error', 'Impossible de supprimer cet enregistrement');
|
|
||||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retour à la liste
|
return $this->redirectToRoute('app_breakday');
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,23 +2,24 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Yeardomaine as Yeardomaine;
|
||||||
|
use App\Entity\Yearproject as Yearproject;
|
||||||
|
use App\Form\YeardomaineType as YeardomaineType;
|
||||||
|
use App\Form\YearprojectType as YearprojectType;
|
||||||
|
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
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\Yearproject as Yearproject;
|
|
||||||
use App\Entity\Yeardomaine as Yeardomaine;
|
|
||||||
use App\Form\YearprojectType as YearprojectType;
|
|
||||||
use App\Form\YeardomaineType as YeardomaineType;
|
|
||||||
|
|
||||||
class BudgetController extends AbstractController
|
class BudgetController extends AbstractController
|
||||||
{
|
{
|
||||||
private $knpSnappy;
|
private $knpSnappy;
|
||||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
|
||||||
|
|
||||||
public function list($id=null,Request $request)
|
public function __construct(\Knp\Snappy\Pdf $knpSnappy)
|
||||||
|
{
|
||||||
|
$this->knpSnappy = $knpSnappy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list($id = null, Request $request)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
@@ -26,289 +27,291 @@ class BudgetController extends AbstractController
|
|||||||
$years = $em
|
$years = $em
|
||||||
->createQueryBuilder('year')
|
->createQueryBuilder('year')
|
||||||
->select('year')
|
->select('year')
|
||||||
->from('App:Year','year')
|
->from('App:Year', 'year')
|
||||||
->orderBy('year.start')
|
->orderBy('year.start')
|
||||||
->setFirstResult(1)
|
->setFirstResult(1)
|
||||||
->getQuery()->getResult();
|
->getQuery()->getResult();
|
||||||
|
|
||||||
// Rechercher l'exercice demandé sinon le dernier
|
// Rechercher l'exercice demandé sinon le dernier
|
||||||
if($id)
|
if ($id) {
|
||||||
$n2=$em->getRepository("App:Year")->find($id);
|
$n2 = $em->getRepository('App:Year')->find($id);
|
||||||
else
|
} else {
|
||||||
$n2=$em->getRepository("App:Year")->findOneBy([],['start'=>'DESC']);
|
$n2 = $em->getRepository('App:Year')->findOneBy([], ['start' => 'DESC']);
|
||||||
|
}
|
||||||
|
|
||||||
// Rechercher l'exercice précendent à celui selectionné
|
// Rechercher l'exercice précendent à celui selectionné
|
||||||
$n1 = $em
|
$n1 = $em
|
||||||
->createQueryBuilder('year')
|
->createQueryBuilder('year')
|
||||||
->select('year')
|
->select('year')
|
||||||
->from('App:Year','year')
|
->from('App:Year', 'year')
|
||||||
->Where('year.end<:start')
|
->Where('year.end<:start')
|
||||||
->setParameter('start',$n2->getStart())
|
->setParameter('start', $n2->getStart())
|
||||||
->orderBy('year.start','DESC')
|
->orderBy('year.start', 'DESC')
|
||||||
->setFirstResult(0)->setMaxResults(1)
|
->setFirstResult(0)->setMaxResults(1)
|
||||||
->getQuery()->getResult();
|
->getQuery()->getResult();
|
||||||
if(empty($n1)) $n1=null;
|
if (empty($n1)) {
|
||||||
else $n1=$n1[0];
|
$n1 = null;
|
||||||
|
} else {
|
||||||
if($n1) {
|
$n1 = $n1[0];
|
||||||
$startn1=clone $n1->getStart();
|
|
||||||
$startn1->setTime(0,0,0);
|
|
||||||
$endn1=clone $n1->getEnd();
|
|
||||||
$endn1->add(new \DateInterval('P1D'))->setTime(0,0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($n2) {
|
if ($n1) {
|
||||||
$startn2=clone $n2->getStart();
|
$startn1 = clone $n1->getStart();
|
||||||
$startn2->setTime(0,0,0);
|
$startn1->setTime(0, 0, 0);
|
||||||
$endn2=clone $n2->getEnd();
|
$endn1 = clone $n1->getEnd();
|
||||||
$endn2->add(new \DateInterval('P1D'))->setTime(0,0,0);
|
$endn1->add(new \DateInterval('P1D'))->setTime(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n2) {
|
||||||
|
$startn2 = clone $n2->getStart();
|
||||||
|
$startn2->setTime(0, 0, 0);
|
||||||
|
$endn2 = clone $n2->getEnd();
|
||||||
|
$endn2->add(new \DateInterval('P1D'))->setTime(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pour chaque domaine
|
// Pour chaque domaine
|
||||||
$tbdomaines=[];
|
$tbdomaines = [];
|
||||||
$domaines = $em->getRepository("App:Domaine")->findBy([],['category'=>'ASC','name'=>'ASC']);
|
$domaines = $em->getRepository('App:Domaine')->findBy([], ['category' => 'ASC', 'name' => 'ASC']);
|
||||||
foreach($domaines as $domaine) {
|
foreach ($domaines as $domaine) {
|
||||||
// Filtre par Domaine
|
// Filtre par Domaine
|
||||||
if($this->get('session')->get('iddomaine')!="all") {
|
if ('all' != $this->get('session')->get('iddomaine')) {
|
||||||
if($domaine->getId()!=$this->get('session')->get('iddomaine'))
|
if ($domaine->getId() != $this->get('session')->get('iddomaine')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// On calcume le réel validé pour les deux périodes pour les domaines
|
// On calcume le réel validé pour les deux périodes pour les domaines
|
||||||
$tbdomaines[$domaine->getId()]=[
|
$tbdomaines[$domaine->getId()] = [
|
||||||
"id" => $domaine->getId(),
|
'id' => $domaine->getId(),
|
||||||
"category" => $domaine->getCategory(),
|
'category' => $domaine->getCategory(),
|
||||||
"name" => $domaine->getCategory()." - ".$domaine->getName(),
|
'name' => $domaine->getCategory().' - '.$domaine->getName(),
|
||||||
|
|
||||||
"nbdayrealn1" => 0,
|
'nbdayrealn1' => 0,
|
||||||
"nbetprealn1" => 0,
|
'nbetprealn1' => 0,
|
||||||
"nbcaarealn1" => 0,
|
'nbcaarealn1' => 0,
|
||||||
"nbdaybudgn1" => 0,
|
'nbdaybudgn1' => 0,
|
||||||
"nbetpbudgn1" => 0,
|
'nbetpbudgn1' => 0,
|
||||||
"nbcaabudgn1" => 0,
|
'nbcaabudgn1' => 0,
|
||||||
|
|
||||||
"nbdayrealn2" => 0,
|
'nbdayrealn2' => 0,
|
||||||
"nbetprealn2" => 0,
|
'nbetprealn2' => 0,
|
||||||
"nbcaarealn2" => 0,
|
'nbcaarealn2' => 0,
|
||||||
"nbdaybudgn2" => 0,
|
'nbdaybudgn2' => 0,
|
||||||
"nbetpbudgn2" => 0,
|
'nbetpbudgn2' => 0,
|
||||||
"nbcaabudgn2" => 0,
|
'nbcaabudgn2' => 0,
|
||||||
|
|
||||||
"projects" => [],
|
'projects' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// Période précédente n1
|
// Période précédente n1
|
||||||
if($n1) {
|
if ($n1) {
|
||||||
// Events
|
// Events
|
||||||
$start=clone $n1->getStart();
|
$start = clone $n1->getStart();
|
||||||
$start->setTime(0,0,0);
|
$start->setTime(0, 0, 0);
|
||||||
$end=clone $n1->getEnd();
|
$end = clone $n1->getEnd();
|
||||||
$end->add(new \DateInterval('P1D'))->setTime(0,0,0);
|
$end->add(new \DateInterval('P1D'))->setTime(0, 0, 0);
|
||||||
|
|
||||||
$events = $em
|
$events = $em
|
||||||
->createQueryBuilder('event')
|
->createQueryBuilder('event')
|
||||||
->select('SUM(event.duration) as somme')
|
->select('SUM(event.duration) as somme')
|
||||||
->from('App:Project','project')
|
->from('App:Project', 'project')
|
||||||
->from('App:Task','task')
|
->from('App:Task', 'task')
|
||||||
->from('App:Event','event')
|
->from('App:Event', 'event')
|
||||||
->Where('project.domaine=:domaine')
|
->Where('project.domaine=:domaine')
|
||||||
->andWhere('task.project=project')
|
->andWhere('task.project=project')
|
||||||
->andWhere('event.task=task')
|
->andWhere('event.task=task')
|
||||||
->andWhere('event.start >=:start')
|
->andWhere('event.start >=:start')
|
||||||
->andWhere('event.end <=:end')
|
->andWhere('event.end <=:end')
|
||||||
->andWhere('event.validate=:validate')
|
->andWhere('event.validate=:validate')
|
||||||
->setParameter('domaine',$domaine)
|
->setParameter('domaine', $domaine)
|
||||||
->setParameter('start',$startn1)
|
->setParameter('start', $startn1)
|
||||||
->setParameter('end',$endn1)
|
->setParameter('end', $endn1)
|
||||||
->setParameter('validate',true)
|
->setParameter('validate', true)
|
||||||
->getQuery()->getResult();
|
->getQuery()->getResult();
|
||||||
$tbdomaines[$domaine->getId()]["nbdayrealn1"]=($events[0]["somme"]?$events[0]["somme"]:0);
|
$tbdomaines[$domaine->getId()]['nbdayrealn1'] = ($events[0]['somme'] ? $events[0]['somme'] : 0);
|
||||||
$tbdomaines[$domaine->getId()]["nbetprealn1"]=$tbdomaines[$domaine->getId()]["nbdayrealn1"]/$n1->getNbday();
|
$tbdomaines[$domaine->getId()]['nbetprealn1'] = $tbdomaines[$domaine->getId()]['nbdayrealn1'] / $n1->getNbday();
|
||||||
|
|
||||||
// Yeardomaine
|
// Yeardomaine
|
||||||
$yeardomaine=$em->getRepository("App:Yeardomaine")->findOneBy(["domaine"=>$domaine,"year"=>$n1]);
|
$yeardomaine = $em->getRepository('App:Yeardomaine')->findOneBy(['domaine' => $domaine, 'year' => $n1]);
|
||||||
if($yeardomaine) {
|
if ($yeardomaine) {
|
||||||
$tbdomaines[$domaine->getId()]["nbcaarealn1"]=$yeardomaine->getCareal();
|
$tbdomaines[$domaine->getId()]['nbcaarealn1'] = $yeardomaine->getCareal();
|
||||||
|
|
||||||
$tbdomaines[$domaine->getId()]["nbdaybudgn1"]=$yeardomaine->getNbdaybudget();
|
$tbdomaines[$domaine->getId()]['nbdaybudgn1'] = $yeardomaine->getNbdaybudget();
|
||||||
$tbdomaines[$domaine->getId()]["nbetpbudgn1"]=$yeardomaine->getNbdaybudget()/$n1->getNbday();
|
$tbdomaines[$domaine->getId()]['nbetpbudgn1'] = $yeardomaine->getNbdaybudget() / $n1->getNbday();
|
||||||
$tbdomaines[$domaine->getId()]["nbcaabudgn1"]=$yeardomaine->getCabudget();
|
$tbdomaines[$domaine->getId()]['nbcaabudgn1'] = $yeardomaine->getCabudget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Période encour n2
|
// Période encour n2
|
||||||
if($n2) {
|
if ($n2) {
|
||||||
$events = $em
|
$events = $em
|
||||||
->createQueryBuilder('event')
|
->createQueryBuilder('event')
|
||||||
->select('SUM(event.duration) as somme')
|
->select('SUM(event.duration) as somme')
|
||||||
->from('App:Project','project')
|
->from('App:Project', 'project')
|
||||||
->from('App:Task','task')
|
->from('App:Task', 'task')
|
||||||
->from('App:Event','event')
|
->from('App:Event', 'event')
|
||||||
->Where('project.domaine=:domaine')
|
->Where('project.domaine=:domaine')
|
||||||
->andWhere('task.project=project')
|
->andWhere('task.project=project')
|
||||||
->andWhere('event.task=task')
|
->andWhere('event.task=task')
|
||||||
->andWhere('event.start >=:start')
|
->andWhere('event.start >=:start')
|
||||||
->andWhere('event.end <=:end')
|
->andWhere('event.end <=:end')
|
||||||
->andWhere('event.validate=:validate')
|
->andWhere('event.validate=:validate')
|
||||||
->setParameter('domaine',$domaine)
|
->setParameter('domaine', $domaine)
|
||||||
->setParameter('start',$startn2)
|
->setParameter('start', $startn2)
|
||||||
->setParameter('end',$endn2)
|
->setParameter('end', $endn2)
|
||||||
->setParameter('validate',true)
|
->setParameter('validate', true)
|
||||||
->getQuery()->getResult();
|
->getQuery()->getResult();
|
||||||
$tbdomaines[$domaine->getId()]["nbdayrealn2"]=($events[0]["somme"]?$events[0]["somme"]:0);
|
$tbdomaines[$domaine->getId()]['nbdayrealn2'] = ($events[0]['somme'] ? $events[0]['somme'] : 0);
|
||||||
$tbdomaines[$domaine->getId()]["nbetprealn2"]=$tbdomaines[$domaine->getId()]["nbdayrealn2"]/$n2->getNbday();
|
$tbdomaines[$domaine->getId()]['nbetprealn2'] = $tbdomaines[$domaine->getId()]['nbdayrealn2'] / $n2->getNbday();
|
||||||
|
|
||||||
// Yeardomaine
|
// Yeardomaine
|
||||||
$yeardomaine=$em->getRepository("App:Yeardomaine")->findOneBy(["domaine"=>$domaine,"year"=>$n2]);
|
$yeardomaine = $em->getRepository('App:Yeardomaine')->findOneBy(['domaine' => $domaine, 'year' => $n2]);
|
||||||
if($yeardomaine) {
|
if ($yeardomaine) {
|
||||||
$tbdomaines[$domaine->getId()]["nbcaarealn2"]=$yeardomaine->getCareal();
|
$tbdomaines[$domaine->getId()]['nbcaarealn2'] = $yeardomaine->getCareal();
|
||||||
|
|
||||||
$tbdomaines[$domaine->getId()]["nbdaybudgn2"]=$yeardomaine->getNbdaybudget();
|
$tbdomaines[$domaine->getId()]['nbdaybudgn2'] = $yeardomaine->getNbdaybudget();
|
||||||
$tbdomaines[$domaine->getId()]["nbetpbudgn2"]=$yeardomaine->getNbdaybudget()/$n2->getNbday();
|
$tbdomaines[$domaine->getId()]['nbetpbudgn2'] = $yeardomaine->getNbdaybudget() / $n2->getNbday();
|
||||||
$tbdomaines[$domaine->getId()]["nbcaabudgn2"]=$yeardomaine->getCabudget();
|
$tbdomaines[$domaine->getId()]['nbcaabudgn2'] = $yeardomaine->getCabudget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pour chaque project du domaine
|
// Pour chaque project du domaine
|
||||||
foreach($domaine->getProjects() as $project) {
|
foreach ($domaine->getProjects() as $project) {
|
||||||
// On calcume le réel validé pour les deux périodes pour les projects
|
// On calcume le réel validé pour les deux périodes pour les projects
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]=[
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()] = [
|
||||||
"id" => $project->getId(),
|
'id' => $project->getId(),
|
||||||
"name" => $project->getCustomer()->getName()." - ".$project->getName(),
|
'name' => $project->getCustomer()->getName().' - '.$project->getName(),
|
||||||
"nbdayrealn1" => 0,
|
'nbdayrealn1' => 0,
|
||||||
"nbetprealn1" => 0,
|
'nbetprealn1' => 0,
|
||||||
"nbcaarealn1" => 0,
|
'nbcaarealn1' => 0,
|
||||||
"nbdaybudgn1" => 0,
|
'nbdaybudgn1' => 0,
|
||||||
"nbetpbudgn1" => 0,
|
'nbetpbudgn1' => 0,
|
||||||
"nbcaabudgn1" => 0,
|
'nbcaabudgn1' => 0,
|
||||||
|
|
||||||
"nbdayrealn2" => 0,
|
'nbdayrealn2' => 0,
|
||||||
"nbetprealn2" => 0,
|
'nbetprealn2' => 0,
|
||||||
"nbcaarealn2" => 0,
|
'nbcaarealn2' => 0,
|
||||||
"nbdaybudgn2" => 0,
|
'nbdaybudgn2' => 0,
|
||||||
"nbetpbudgn2" => 0,
|
'nbetpbudgn2' => 0,
|
||||||
"nbcaabudgn2" => 0,
|
'nbcaabudgn2' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Période précédente n1
|
// Période précédente n1
|
||||||
if($n1) {
|
if ($n1) {
|
||||||
$events = $em
|
$events = $em
|
||||||
->createQueryBuilder('event')
|
->createQueryBuilder('event')
|
||||||
->select('SUM(event.duration) as somme')
|
->select('SUM(event.duration) as somme')
|
||||||
->from('App:Task','task')
|
->from('App:Task', 'task')
|
||||||
->from('App:Event','event')
|
->from('App:Event', 'event')
|
||||||
->Where('task.project=:project')
|
->Where('task.project=:project')
|
||||||
->andWhere('event.task=task')
|
->andWhere('event.task=task')
|
||||||
->andWhere('event.start >=:start')
|
->andWhere('event.start >=:start')
|
||||||
->andWhere('event.end <=:end')
|
->andWhere('event.end <=:end')
|
||||||
->andWhere('event.validate=:validate')
|
->andWhere('event.validate=:validate')
|
||||||
->setParameter('project',$project)
|
->setParameter('project', $project)
|
||||||
->setParameter('start',$startn1)
|
->setParameter('start', $startn1)
|
||||||
->setParameter('end',$endn1)
|
->setParameter('end', $endn1)
|
||||||
->setParameter('validate',true)
|
->setParameter('validate', true)
|
||||||
->getQuery()->getResult();
|
->getQuery()->getResult();
|
||||||
$nbdayrealn1=($events[0]["somme"]?$events[0]["somme"]:0);
|
$nbdayrealn1 = ($events[0]['somme'] ? $events[0]['somme'] : 0);
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbdayrealn1"]=$nbdayrealn1;
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbdayrealn1'] = $nbdayrealn1;
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbetprealn1"]=$nbdayrealn1/$n1->getNbday();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbetprealn1'] = $nbdayrealn1 / $n1->getNbday();
|
||||||
|
|
||||||
// Yearproject
|
// Yearproject
|
||||||
$yearproject=$em->getRepository("App:Yearproject")->findOneBy(["project"=>$project,"year"=>$n1]);
|
$yearproject = $em->getRepository('App:Yearproject')->findOneBy(['project' => $project, 'year' => $n1]);
|
||||||
if($yearproject) {
|
if ($yearproject) {
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbcaarealn1"]=$yearproject->getCareal();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbcaarealn1'] = $yearproject->getCareal();
|
||||||
|
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbdaybudgn1"]=$yearproject->getNbdaybudget();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbdaybudgn1'] = $yearproject->getNbdaybudget();
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbetpbudgn1"]=$yearproject->getNbdaybudget()/$n1->getNbday();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbetpbudgn1'] = $yearproject->getNbdaybudget() / $n1->getNbday();
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbcaabudgn1"]=$yearproject->getCabudget();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbcaabudgn1'] = $yearproject->getCabudget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Période encour n2
|
// Période encour n2
|
||||||
if($n2) {
|
if ($n2) {
|
||||||
$start=$n2->getStart()->setTime(0,0,0);;
|
$start = $n2->getStart()->setTime(0, 0, 0);
|
||||||
$end=$n2->getEnd()->add(new \DateInterval('P1D'))->setTime(0,0,0);
|
$end = $n2->getEnd()->add(new \DateInterval('P1D'))->setTime(0, 0, 0);
|
||||||
$events = $em
|
$events = $em
|
||||||
->createQueryBuilder('event')
|
->createQueryBuilder('event')
|
||||||
->select('SUM(event.duration) as somme')
|
->select('SUM(event.duration) as somme')
|
||||||
->from('App:Task','task')
|
->from('App:Task', 'task')
|
||||||
->from('App:Event','event')
|
->from('App:Event', 'event')
|
||||||
->andWhere('task.project=:project')
|
->andWhere('task.project=:project')
|
||||||
->andWhere('event.task=task')
|
->andWhere('event.task=task')
|
||||||
->andWhere('event.start >=:start')
|
->andWhere('event.start >=:start')
|
||||||
->andWhere('event.end <=:end')
|
->andWhere('event.end <=:end')
|
||||||
->andWhere('event.validate=:validate')
|
->andWhere('event.validate=:validate')
|
||||||
->setParameter('project',$project)
|
->setParameter('project', $project)
|
||||||
->setParameter('start',$startn2)
|
->setParameter('start', $startn2)
|
||||||
->setParameter('end',$endn2)
|
->setParameter('end', $endn2)
|
||||||
->setParameter('validate',true)
|
->setParameter('validate', true)
|
||||||
->getQuery()->getResult();
|
->getQuery()->getResult();
|
||||||
$nbdayrealn2=($events[0]["somme"]?$events[0]["somme"]:0);
|
$nbdayrealn2 = ($events[0]['somme'] ? $events[0]['somme'] : 0);
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbdayrealn2"]=$nbdayrealn2;
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbdayrealn2'] = $nbdayrealn2;
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbetprealn2"]=$nbdayrealn2/$n2->getNbday();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbetprealn2'] = $nbdayrealn2 / $n2->getNbday();
|
||||||
|
|
||||||
// Yearproject
|
// Yearproject
|
||||||
$yearproject=$em->getRepository("App:Yearproject")->findOneBy(["project"=>$project,"year"=>$n2]);
|
$yearproject = $em->getRepository('App:Yearproject')->findOneBy(['project' => $project, 'year' => $n2]);
|
||||||
if($yearproject) {
|
if ($yearproject) {
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbcaarealn2"]=$yearproject->getCareal();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbcaarealn2'] = $yearproject->getCareal();
|
||||||
|
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbdaybudgn2"]=$yearproject->getNbdaybudget();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbdaybudgn2'] = $yearproject->getNbdaybudget();
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbetpbudgn2"]=$yearproject->getNbdaybudget()/$n2->getNbday();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbetpbudgn2'] = $yearproject->getNbdaybudget() / $n2->getNbday();
|
||||||
$tbdomaines[$domaine->getId()]["projects"][$project->getId()]["nbcaabudgn2"]=$yearproject->getCabudget();
|
$tbdomaines[$domaine->getId()]['projects'][$project->getId()]['nbcaabudgn2'] = $yearproject->getCabudget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$project->getActive()&&$nbdayrealn1==0&&$nbdayrealn2==0)
|
if (!$project->getActive() && 0 == $nbdayrealn1 && 0 == $nbdayrealn2) {
|
||||||
unset($tbdomaines[$domaine->getId()]["projects"][$project->getId()]);
|
unset($tbdomaines[$domaine->getId()]['projects'][$project->getId()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->query->get('fgprint')) {
|
||||||
if($request->query->get('fgprint')) {
|
$render = $this->renderView('Budget/list.html.twig', [
|
||||||
$render = $this->renderView('Budget/list.html.twig',[
|
'useheader' => true,
|
||||||
"useheader" => true,
|
'usesidebar' => true,
|
||||||
"usesidebar" => true,
|
'domaines' => $tbdomaines,
|
||||||
"domaines" => $tbdomaines,
|
'n1' => $n1,
|
||||||
"n1" => $n1,
|
'n2' => $n2,
|
||||||
"n2" => $n2,
|
'years' => $years,
|
||||||
"years" => $years,
|
'fgprint' => true,
|
||||||
"fgprint" => true,
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new PdfResponse(
|
return new PdfResponse(
|
||||||
$this->knpSnappy->getOutputFromHtml($render),
|
$this->knpSnappy->getOutputFromHtml($render),
|
||||||
'domaines.pdf'
|
'domaines.pdf'
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
return $this->render('Budget/list.html.twig', [
|
||||||
return $this->render('Budget/list.html.twig',[
|
'useheader' => true,
|
||||||
"useheader" => true,
|
'usesidebar' => true,
|
||||||
"usesidebar" => true,
|
'domaines' => $tbdomaines,
|
||||||
"domaines" => $tbdomaines,
|
'n1' => $n1,
|
||||||
"n1" => $n1,
|
'n2' => $n2,
|
||||||
"n2" => $n2,
|
'years' => $years,
|
||||||
"years" => $years,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($type,$id,$year,Request $request)
|
public function update($type, $id, $year, Request $request)
|
||||||
{
|
{
|
||||||
// Initialisation de l'enregistrement
|
// Initialisation de l'enregistrement
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
// Returnto
|
// Returnto
|
||||||
$returnto=$request->get("returnto");
|
$returnto = $request->get('returnto');
|
||||||
|
|
||||||
// Recherche de l'exercice
|
// Recherche de l'exercice
|
||||||
$year=$em->getRepository("App:Year")->find($year);
|
$year = $em->getRepository('App:Year')->find($year);
|
||||||
|
|
||||||
// Recherche de la ligne projet/domaine associée à l'exercice
|
// Recherche de la ligne projet/domaine associée à l'exercice
|
||||||
if($type=="project") {
|
if ('project' == $type) {
|
||||||
$project=$em->getRepository("App:Project")->find($id);
|
$project = $em->getRepository('App:Project')->find($id);
|
||||||
$data=$em->getRepository("App:Yearproject")->findOneBy(["year"=>$year,"project"=>$project]);
|
$data = $em->getRepository('App:Yearproject')->findOneBy(['year' => $year, 'project' => $project]);
|
||||||
if(!$data) {
|
if (!$data) {
|
||||||
$data=new Yearproject;
|
$data = new Yearproject();
|
||||||
$data->setYear($year);
|
$data->setYear($year);
|
||||||
$data->setProject($project);
|
$data->setProject($project);
|
||||||
$em->persist($data);
|
$em->persist($data);
|
||||||
@@ -316,13 +319,12 @@ class BudgetController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$form = $this->createForm(YearprojectType::class,$data,array("mode"=>"update"));
|
$form = $this->createForm(YearprojectType::class, $data, ['mode' => 'update']);
|
||||||
}
|
} else {
|
||||||
else {
|
$domaine = $em->getRepository('App:Domaine')->find($id);
|
||||||
$domaine=$em->getRepository("App:Domaine")->find($id);
|
$data = $em->getRepository('App:Yeardomaine')->findOneBy(['year' => $year, 'domaine' => $domaine]);
|
||||||
$data=$em->getRepository("App:Yeardomaine")->findOneBy(["year"=>$year,"domaine"=>$domaine]);
|
if (!$data) {
|
||||||
if(!$data) {
|
$data = new Yeardomaine();
|
||||||
$data=new Yeardomaine;
|
|
||||||
$data->setYear($year);
|
$data->setYear($year);
|
||||||
$data->setDomaine($domaine);
|
$data->setDomaine($domaine);
|
||||||
$em->persist($data);
|
$em->persist($data);
|
||||||
@@ -330,15 +332,14 @@ class BudgetController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$form = $this->createForm(YeardomaineType::class,$data,array("mode"=>"update"));
|
$form = $this->createForm(YeardomaineType::class, $data, ['mode' => 'update']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Récupération des data du formulaire
|
// Récupération des data du formulaire
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
// Sur erreur
|
// Sur erreur
|
||||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
$this->getErrorForm(null, $form, $request, $data, 'update');
|
||||||
|
|
||||||
// Sur validation
|
// Sur validation
|
||||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||||
@@ -347,14 +348,15 @@ class BudgetController extends AbstractController
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// Retour à la liste
|
// Retour à la liste
|
||||||
if($returnto)
|
if ($returnto) {
|
||||||
return $this->redirectToRoute("app_budget",["id"=>$returnto]);
|
return $this->redirectToRoute('app_budget', ['id' => $returnto]);
|
||||||
else
|
} else {
|
||||||
return $this->redirectToRoute("app_budget",["id"=>$year->getId()]);
|
return $this->redirectToRoute('app_budget', ['id' => $year->getId()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage du formulaire
|
// Affichage du formulaire
|
||||||
if($request->query->get('fgprint')) {
|
if ($request->query->get('fgprint')) {
|
||||||
$render = $this->renderView('Budget/edit.html.twig', [
|
$render = $this->renderView('Budget/edit.html.twig', [
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
@@ -364,16 +366,15 @@ class BudgetController extends AbstractController
|
|||||||
'year' => $year,
|
'year' => $year,
|
||||||
'mode' => 'update',
|
'mode' => 'update',
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
"fgprint" => true,
|
'fgprint' => true,
|
||||||
"returnto" => $returnto,
|
'returnto' => $returnto,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new PdfResponse(
|
return new PdfResponse(
|
||||||
$this->knpSnappy->getOutputFromHtml($render),
|
$this->knpSnappy->getOutputFromHtml($render),
|
||||||
'budget.pdf'
|
'budget.pdf'
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return $this->render('Budget/edit.html.twig', [
|
return $this->render('Budget/edit.html.twig', [
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
@@ -383,24 +384,25 @@ class BudgetController extends AbstractController
|
|||||||
'year' => $year,
|
'year' => $year,
|
||||||
'mode' => 'update',
|
'mode' => 'update',
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
"returnto" => $returnto,
|
'returnto' => $returnto,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
protected function getErrorForm($id, $form, $request, $data, $mode)
|
||||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
{
|
||||||
|
if ($form->get('submit')->isClicked() && 'delete' == $mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
if ($form->get('submit')->isClicked() && 'submit' == $mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||||
$this->get('session')->getFlashBag()->clear();
|
$this->get('session')->getFlashBag()->clear();
|
||||||
|
|
||||||
$errors = $form->getErrors();
|
$errors = $form->getErrors();
|
||||||
foreach( $errors as $error ) {
|
foreach ($errors as $error) {
|
||||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
$request->getSession()->getFlashBag()->add('error', $error->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,113 +2,82 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Form\CronType;
|
||||||
|
use App\Repository\CronRepository;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
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 Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use App\Entity\Cron as Entity;
|
|
||||||
use App\Form\CronType as Form;
|
|
||||||
|
|
||||||
class CronController extends AbstractController
|
class CronController extends AbstractController
|
||||||
{
|
{
|
||||||
private $data = "cron";
|
private EntityManagerInterface $em;
|
||||||
private $route = "app_cron";
|
private CronRepository $cronRepository;
|
||||||
private $render = "Cron/";
|
|
||||||
private $entity = "App:Cron";
|
public function __construct(EntityManagerInterface $em, CronRepository $cronRepository)
|
||||||
|
{
|
||||||
|
$this->em = $em;
|
||||||
|
$this->cronRepository = $cronRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public function list()
|
public function list()
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$crons = $this->cronRepository->findAll();
|
||||||
$datas = $em->getRepository($this->entity)->findAll();
|
|
||||||
|
|
||||||
return $this->render($this->render.'list.html.twig',[
|
return $this->render('Cron/list.html.twig', [
|
||||||
$this->data."s" => $datas,
|
'crons' => $crons,
|
||||||
"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,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($id, Request $request)
|
||||||
|
{
|
||||||
|
$cron = $this->cronRepository->find($id);
|
||||||
|
if (!$cron) {
|
||||||
|
throw new NotFoundHttpException('La ressource demandée est introuvable.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = $this->createForm(CronType::class, $cron, ['mode' => 'update']);
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$this->em->persist($cron);
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
|
return $this->redirectToRoute('app_cron');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('Cron/edit.html.twig', [
|
||||||
|
'useheader' => true,
|
||||||
|
'usesidebar' => true,
|
||||||
|
'cron' => $cron,
|
||||||
'mode' => 'update',
|
'mode' => 'update',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log()
|
public function log()
|
||||||
{
|
{
|
||||||
return $this->render($this->render.'logs.html.twig', [
|
return $this->render('Cron/logs.html.twig', [
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getlog(Request $request, $id)
|
public function getlog($id)
|
||||||
{
|
{
|
||||||
|
|
||||||
$path = $this->getParameter('kernel.project_dir');
|
$path = $this->getParameter('kernel.project_dir');
|
||||||
if($id=="dump")
|
if ('dump' == $id) {
|
||||||
$file = $path . '/var/log/' . $this->getParameter("appAlias") . '.sql';
|
$file = $path.'/var/log/'.$this->getParameter('appAlias').'.sql';
|
||||||
else
|
} else {
|
||||||
$file = $path . '/var/log/'.$id.'.log';
|
$file = $path.'/var/log/'.$id.'.log';
|
||||||
|
}
|
||||||
|
|
||||||
$response = new BinaryFileResponse($file);
|
$response = new BinaryFileResponse($file);
|
||||||
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);
|
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);
|
||||||
|
|
||||||
return $response;
|
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -2,51 +2,53 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use App\Entity\Domaine;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use App\Entity\Service;
|
||||||
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\Entity\Task as Entity;
|
||||||
use App\Form\TaskType as Form;
|
use App\Form\TaskType as Form;
|
||||||
|
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class TaskController extends AbstractController
|
class TaskController extends AbstractController
|
||||||
{
|
{
|
||||||
private $data = "task";
|
private $data = 'task';
|
||||||
private $route = "app_task";
|
private $route = 'app_task';
|
||||||
private $render = "Task/";
|
private $render = 'Task/';
|
||||||
private $entity = "App:Task";
|
private $entity = 'App:Task';
|
||||||
|
|
||||||
private $knpSnappy;
|
private $knpSnappy;
|
||||||
public function __construct(\Knp\Snappy\Pdf $knpSnappy) { $this->knpSnappy = $knpSnappy; }
|
|
||||||
|
public function __construct(\Knp\Snappy\Pdf $knpSnappy)
|
||||||
|
{
|
||||||
|
$this->knpSnappy = $knpSnappy;
|
||||||
|
}
|
||||||
|
|
||||||
public function list(Request $request)
|
public function list(Request $request)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$services=$em->getRepository("App:Service")->findAllTaskActive($this->get('session')->get('activeproject'),$this->get('session')->get('idservice'));
|
$services = $em->getRepository(Service::class)->findAllTaskActive($this->get('session')->get('activeproject'), $this->get('session')->get('idservice'));
|
||||||
$domaines=$em->getRepository("App:Domaine")->findAllTaskActive($this->get('session')->get('activeproject'),$this->get('session')->get('iddomaine'));
|
$domaines = $em->getRepository(Domaine::class)->findAllTaskActive($this->get('session')->get('activeproject'), $this->get('session')->get('iddomaine'));
|
||||||
|
|
||||||
if($request->query->get('fgprint')) {
|
if ($request->query->get('fgprint')) {
|
||||||
$render = $this->renderView($this->render.'list.html.twig',[
|
$render = $this->renderView($this->render.'list.html.twig', [
|
||||||
"services" => $services,
|
'services' => $services,
|
||||||
"domaines" => $domaines,
|
'domaines' => $domaines,
|
||||||
"useheader" => true,
|
'useheader' => true,
|
||||||
"usesidebar" => true,
|
'usesidebar' => true,
|
||||||
"fgprint" => true,
|
'fgprint' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new PdfResponse(
|
return new PdfResponse(
|
||||||
$this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]),
|
$this->knpSnappy->getOutputFromHtml($render, ['orientation' => 'Landscape']),
|
||||||
'taches.pdf'
|
'taches.pdf'
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
return $this->render($this->render.'list.html.twig', [
|
||||||
return $this->render($this->render.'list.html.twig',[
|
'services' => $services,
|
||||||
"services" => $services,
|
'domaines' => $domaines,
|
||||||
"domaines" => $domaines,
|
'useheader' => true,
|
||||||
"useheader" => true,
|
'usesidebar' => true,
|
||||||
"usesidebar" => true,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,17 +58,17 @@ class TaskController extends AbstractController
|
|||||||
// Initialisation de l'enregistrement
|
// Initialisation de l'enregistrement
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$data = new Entity();
|
$data = new Entity();
|
||||||
$defaultnature = $em->getRepository("App:Nature")->findOneBy(['name' => 'Prestation']);
|
$defaultnature = $em->getRepository('App:Nature')->findOneBy(['name' => 'Prestation']);
|
||||||
$data->setNature($defaultnature);
|
$data->setNature($defaultnature);
|
||||||
$data->setActive(true);
|
$data->setActive(true);
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
$form = $this->createForm(Form::class, $data, ['mode' => 'submit']);
|
||||||
|
|
||||||
// Récupération des data du formulaire
|
// Récupération des data du formulaire
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
// Sur erreur
|
// Sur erreur
|
||||||
$this->getErrorForm(null,$form,$request,$data,"submit");
|
$this->getErrorForm(null, $form, $request, $data, 'submit');
|
||||||
|
|
||||||
// Sur validation
|
// Sur validation
|
||||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||||
@@ -84,24 +86,24 @@ class TaskController extends AbstractController
|
|||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
$this->data => $data,
|
||||||
'mode' => 'submit',
|
'mode' => 'submit',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id,Request $request)
|
public function update($id, Request $request)
|
||||||
{
|
{
|
||||||
// Initialisation de l'enregistrement
|
// Initialisation de l'enregistrement
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$data=$em->getRepository($this->entity)->find($id);
|
$data = $em->getRepository($this->entity)->find($id);
|
||||||
|
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
$form = $this->createForm(Form::class, $data, ['mode' => 'update']);
|
||||||
|
|
||||||
// Récupération des data du formulaire
|
// Récupération des data du formulaire
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
// Sur erreur
|
// Sur erreur
|
||||||
$this->getErrorForm(null,$form,$request,$data,"update");
|
$this->getErrorForm(null, $form, $request, $data, 'update');
|
||||||
|
|
||||||
// Sur validation
|
// Sur validation
|
||||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||||
@@ -114,51 +116,50 @@ class TaskController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Affichage du formulaire
|
// Affichage du formulaire
|
||||||
if($request->query->get('fgprint')) {
|
if ($request->query->get('fgprint')) {
|
||||||
$render = $this->renderView($this->render.'edit.html.twig', [
|
$render = $this->renderView($this->render.'edit.html.twig', [
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
$this->data => $data,
|
||||||
'mode' => 'update',
|
'mode' => 'update',
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
"fgprint" => true,
|
'fgprint' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new PdfResponse(
|
return new PdfResponse(
|
||||||
$this->knpSnappy->getOutputFromHtml($render),
|
$this->knpSnappy->getOutputFromHtml($render),
|
||||||
'tache.pdf'
|
'tache.pdf'
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return $this->render($this->render.'edit.html.twig', [
|
return $this->render($this->render.'edit.html.twig', [
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
$this->data => $data,
|
||||||
'mode' => 'update',
|
'mode' => 'update',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id,Request $request)
|
public function delete($id, Request $request)
|
||||||
{
|
{
|
||||||
// Initialisation de l'enregistrement
|
// Initialisation de l'enregistrement
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$data=$em->getRepository($this->entity)->find($id);
|
$data = $em->getRepository($this->entity)->find($id);
|
||||||
|
|
||||||
// Controle avant suppression
|
// Controle avant suppression
|
||||||
$error=false;
|
$error = false;
|
||||||
if($error)
|
if ($error) {
|
||||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
return $this->redirectToRoute($this->route.'_update', ['id' => $id]);
|
||||||
else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$em->remove($data);
|
$em->remove($data);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
}
|
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||||
catch(\Doctrine\DBAL\DBALException $e) {
|
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$this->get('session')->getFlashBag()->add('error', 'Impossible de supprimer cet enregistrement');
|
$this->get('session')->getFlashBag()->add('error', 'Impossible de supprimer cet enregistrement');
|
||||||
return $this->redirectToRoute($this->route."_update",["id"=>$id]);
|
|
||||||
|
return $this->redirectToRoute($this->route.'_update', ['id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retour à la liste
|
// Retour à la liste
|
||||||
@@ -166,34 +167,41 @@ class TaskController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activeproject() {
|
public function activeproject()
|
||||||
$this->get('session')->set('activeproject',!$this->get('session')->get('activeproject'));
|
{
|
||||||
|
$this->get('session')->set('activeproject', !$this->get('session')->get('activeproject'));
|
||||||
|
|
||||||
return $this->redirectToRoute($this->route);
|
return $this->redirectToRoute($this->route);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activetask() {
|
public function activetask()
|
||||||
$this->get('session')->set('activetask',!$this->get('session')->get('activetask'));
|
{
|
||||||
|
$this->get('session')->set('activetask', !$this->get('session')->get('activetask'));
|
||||||
|
|
||||||
return $this->redirectToRoute($this->route);
|
return $this->redirectToRoute($this->route);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function viewservice() {
|
public function viewservice()
|
||||||
$this->get('session')->set('viewservice',!$this->get('session')->get('viewservice'));
|
{
|
||||||
|
$this->get('session')->set('viewservice', !$this->get('session')->get('viewservice'));
|
||||||
|
|
||||||
return $this->redirectToRoute($this->route);
|
return $this->redirectToRoute($this->route);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
protected function getErrorForm($id, $form, $request, $data, $mode)
|
||||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
{
|
||||||
|
if ($form->get('submit')->isClicked() && 'delete' == $mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->get('submit')->isClicked() && $mode=="submit") {
|
if ($form->get('submit')->isClicked() && 'submit' == $mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||||
$this->get('session')->getFlashBag()->clear();
|
$this->get('session')->getFlashBag()->clear();
|
||||||
|
|
||||||
$errors = $form->getErrors();
|
$errors = $form->getErrors();
|
||||||
foreach( $errors as $error ) {
|
foreach ($errors as $error) {
|
||||||
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
|
$request->getSession()->getFlashBag()->add('error', $error->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,12 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event
|
* Event
|
||||||
@@ -30,13 +26,11 @@ class Breakday
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="start", type="datetime", unique=true)
|
* @ORM\Column(name="start", type="datetime", unique=true)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private $start;
|
private $start;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="end", type="datetime")
|
* @ORM\Column(name="end", type="datetime")
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private $end;
|
private $end;
|
||||||
|
|
||||||
@@ -45,24 +39,24 @@ class Breakday
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart(): ?\DateTimeInterface
|
public function getStart(): ?\DateTime
|
||||||
{
|
{
|
||||||
return $this->start;
|
return $this->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStart(\DateTimeInterface $start): self
|
public function setStart(\DateTime $start): self
|
||||||
{
|
{
|
||||||
$this->start = $start;
|
$this->start = $start;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEnd(): ?\DateTimeInterface
|
public function getEnd(): ?\DateTime
|
||||||
{
|
{
|
||||||
return $this->end;
|
return $this->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEnd(\DateTimeInterface $end): self
|
public function setEnd(\DateTime $end): self
|
||||||
{
|
{
|
||||||
$this->end = $end;
|
$this->end = $end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user