Skip to content

Commit

Permalink
Merge pull request #34 from H2-invent/feature/policy
Browse files Browse the repository at this point in the history
Feature/policy
  • Loading branch information
holzi1005 authored Jul 7, 2020
2 parents 281ea32 + af5b428 commit 0bac745
Show file tree
Hide file tree
Showing 49 changed files with 2,722 additions and 80 deletions.
30 changes: 21 additions & 9 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,24 @@
color: whitesmoke !important;
}

.bg-forms {
background-color: #996800;
color: whitesmoke !important;
}

.bg-policy {
background-color: #4b515d;
color: whitesmoke !important;
}

/* poppins-regular - latin */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
src: url('../fonts/poppins-v9-latin-regular.eot'); /* IE9 Compat Modes */
src: local('Poppins Regular'), local('Poppins-Regular'),
url('../fonts/poppins-v9-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('../fonts/poppins-v9-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('../fonts/poppins-v9-latin-regular.woff') format('woff'), /* Modern Browsers */
url('../fonts/poppins-v9-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('../fonts/poppins-v9-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('../fonts/poppins-v9-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ url('../fonts/poppins-v9-latin-regular.woff') format('woff'), /* Modern Browsers */ url('../fonts/poppins-v9-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('../fonts/poppins-v9-latin-regular.svg#Poppins') format('svg'); /* Legacy iOS */
}
body {
Expand Down Expand Up @@ -299,15 +307,15 @@ label.required:after {
visibility: hidden;
width: 100%;

background-color: var(--contrast-base);
background-color: #34ce57;
color: #fff;
text-align: center;
border-radius: 2px;
padding: 16px;
position: fixed;
z-index: 1;
right: 0;
bottom: 30px;
bottom: 0;
font-size: 17px;
}

Expand All @@ -323,7 +331,7 @@ label.required:after {
opacity: 0;
}
to {
bottom: 30px;
bottom: 0;
opacity: 1;
}
}
Expand All @@ -334,14 +342,14 @@ label.required:after {
opacity: 0;
}
to {
bottom: 30px;
bottom: 0;
opacity: 1;
}
}

@-webkit-keyframes fadeout {
from {
bottom: 30px;
bottom: 0;
opacity: 1;
}
to {
Expand All @@ -352,11 +360,15 @@ label.required:after {

@keyframes fadeout {
from {
bottom: 30px;
bottom: 0;
opacity: 1;
}
to {
bottom: 0;
opacity: 0;
}
}

.dropdown-toggle::after {
content: none !important;
}
Binary file added public/images/contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/information.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 37 additions & 1 deletion src/Controller/AssignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use App\Entity\AuditTom;
use App\Entity\Datenweitergabe;
use App\Entity\Forms;
use App\Entity\Policies;
use App\Entity\VVT;
use App\Entity\VVTDsfa;
use App\Service\AssignService;
Expand All @@ -24,12 +26,16 @@ public function index(Request $request, AssignService $assignService)
$assignVvt = $this->getUser()->getAssignedVvts()->toarray();
$assignAudit = $this->getUser()->getAssignedAudits()->toarray();
$assignDsfa = $this->getUser()->getAssignedDsfa()->toarray();
$assignForms = $this->getUser()->getAssignedForms()->toarray();
$assignPolicies = $this->getUser()->getAssignedPolicies()->toarray();

return $this->render('assign/index.html.twig', [
'assignDaten' => $assignDatenweitergabe,
'assignVvt' => $assignVvt,
'assignAudit' => $assignAudit,
'assignDsfa' => $assignDsfa
'assignDsfa' => $assignDsfa,
'assignForms' => $assignForms,
'assignPolicies' => $assignPolicies
]);
}

Expand Down Expand Up @@ -92,4 +98,34 @@ public function assignDsfa(Request $request, AssignService $assignService, Secur
$res = $assignService->assignDsfa($request, $dsfa);
return $this->redirect($request->headers->get('referer'));
}

/**
* @Route("/assign/form", name="assign_form")
*/
public function assignForm(Request $request, AssignService $assignService, SecurityService $securityService)
{
$team = $this->getUser()->getTeam();
$form = $this->getDoctrine()->getRepository(Forms::class)->find($request->get('id'));
if ($securityService->teamDataCheck($form, $team) === false) {
return $this->redirectToRoute('forms');
}

$res = $assignService->assignForm($request, $form);
return $this->redirect($request->headers->get('referer'));
}

/**
* @Route("/assign/policy", name="assign_policy")
*/
public function assignPolicy(Request $request, AssignService $assignService, SecurityService $securityService)
{
$team = $this->getUser()->getTeam();
$policy = $this->getDoctrine()->getRepository(Policies::class)->find($request->get('id'));
if ($securityService->teamDataCheck($policy, $team) === false) {
return $this->redirectToRoute('policies');
}

$res = $assignService->assignPolicy($request, $policy);
return $this->redirect($request->headers->get('referer'));
}
}
42 changes: 42 additions & 0 deletions src/Controller/BerichtController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Entity\AkademieBuchungen;
use App\Entity\AuditTom;
use App\Entity\Datenweitergabe;
use App\Entity\Policies;
use App\Entity\Tom;
use App\Entity\Vorfall;
use App\Entity\VVT;
Expand Down Expand Up @@ -293,4 +294,45 @@ public function berichtVorfall(DompdfWrapper $wrapper, Request $request)
// Send some text response
return new Response("The PDF file has been succesfully generated !");
}

/**
* @Route("/bericht/policy", name="bericht_policy")
*/
public function berichtPolicy(DompdfWrapper $wrapper, Request $request)
{

$req = $request->get('id');

$team = $this->getUser()->getTeam();

if ($req) {
$policies = $this->getDoctrine()->getRepository(Policies::class)->findBy(array('id' => $req));
} else {
$policies = $this->getDoctrine()->getRepository(Policies::class)->findBy(array('team' => $team, 'activ' => true), ['createdAt' => 'DESC']);
}

if (count($policies) < 1) {
return $this->redirectToRoute('bericht');
}

// Center Team authentication
if ($team === null || $policies[0]->getTeam() !== $team) {
return $this->redirectToRoute('dashboard');
}

// Retrieve the HTML generated in our twig file
$html = $this->renderView('bericht/policy.html.twig', [
'daten' => $policies,
'titel' => 'Bericht zu Datenschutzrichtlinien',
'team' => $this->getUser()->getTeam(),
'all' => $request->get('all'),
]);

//Generate PDF File for Download
$response = $wrapper->getStreamResponse($html, "Datenschutzrichtlinie.pdf");
$response->send();

// Send some text response
return new Response("The PDF file has been succesfully generated !");
}
}
13 changes: 9 additions & 4 deletions src/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use App\Entity\AkademieBuchungen;
use App\Entity\AuditTom;
use App\Entity\Datenweitergabe;
use App\Entity\Forms;
use App\Entity\Kontakte;
use App\Entity\Policies;
use App\Entity\Tom;
use App\Entity\VVT;
use App\Entity\VVTDsfa;
Expand All @@ -34,12 +36,14 @@ public function dashboard()
}

$audit = $this->getDoctrine()->getRepository(AuditTom::class)->findAllByTeam($team);
$daten = $this->getDoctrine()->getRepository(Datenweitergabe::class)->findBy(array('team'=>$team,'activ'=>true,'art'=>1));
$av = $this->getDoctrine()->getRepository(Datenweitergabe::class)->findBy(array('team'=>$team,'activ'=>true,'art'=>2));
$daten = $this->getDoctrine()->getRepository(Datenweitergabe::class)->findBy(array('team' => $team, 'activ' => true, 'art' => 1));
$av = $this->getDoctrine()->getRepository(Datenweitergabe::class)->findBy(array('team' => $team, 'activ' => true, 'art' => 2));
$vvt = $this->getDoctrine()->getRepository(VVT::class)->findActivByTeam($team);
$vvtDsfa = $this->getDoctrine()->getRepository(VVTDsfa::class)->findActivByTeam($team);
$kontakte = $this->getDoctrine()->getRepository(Kontakte::class)->findActivByTeam($team);
$tom = $this->getDoctrine()->getRepository(Tom::class)->findActivByTeam($team);
$forms = $this->getDoctrine()->getRepository(Forms::class)->findPublicByTeam($team);
$policies = $this->getDoctrine()->getRepository(Policies::class)->findPublicByTeam($team);

$qb = $this->getDoctrine()->getRepository(AuditTom::class)->createQueryBuilder('audit');
$qb->andWhere('audit.team = :team')
Expand Down Expand Up @@ -77,7 +81,6 @@ public function dashboard()
$buchungen = $this->getDoctrine()->getRepository(AkademieBuchungen::class)->findActivBuchungenByUser($this->getUser());

return $this->render('dashboard/index.html.twig', [
'controller_name' => 'DashboardController',
'team' => $team,
'audit' => $audit,
'daten' => $daten,
Expand All @@ -93,7 +96,9 @@ public function dashboard()
'assignVvt' => $assignVvt,
'assignAudit' => $assignAudit,
'assignDsfa' => $assignDsfa,
'akademie' => $buchungen
'akademie' => $buchungen,
'forms' => $forms,
'policies' => $policies
]);
}
}
142 changes: 142 additions & 0 deletions src/Controller/FormsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php

namespace App\Controller;

use App\Entity\Forms;
use App\Service\AssignService;
use App\Service\FormsService;
use App\Service\SecurityService;
use League\Flysystem\FilesystemInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Validator\ValidatorInterface;

class FormsController extends AbstractController
{
/**
* @Route("/forms", name="forms")
*/
public function indexForms(SecurityService $securityService)
{
$team = $this->getUser()->getTeam();
if ($securityService->teamCheck($team) === false) {
return $this->redirectToRoute('dashboard');
}

$daten = $this->getDoctrine()->getRepository(Forms::class)->findBy(array('team' => $team, 'activ' => true));
return $this->render('forms/index.html.twig', [
'table' => $daten,
'titel' => 'Formulare',
]);
}

/**
* @Route("/forms/new", name="forms_new")
*/
public function addForms(ValidatorInterface $validator, Request $request, FormsService $formsService, SecurityService $securityService)
{
$team = $this->getUser()->getTeam();
if ($securityService->teamCheck($team) === false) {
return $this->redirectToRoute('dashboard');
}

$daten = $formsService->newForm($this->getUser());

$form = $formsService->createForm($daten, $team);
$form->handleRequest($request);

$errors = array();
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$daten = $form->getData();
$errors = $validator->validate($daten);
if (count($errors) == 0) {

$em->persist($daten);
$em->flush();
return $this->redirectToRoute('forms');
}
}
return $this->render('forms/new.html.twig', [
'form' => $form->createView(),
'errors' => $errors,
'title' => 'Formular erstellen/hochladen',
'daten' => $daten,
'activ' => $daten->getActiv()
]);
}

/**
* @Route("/forms/edit", name="forms_edit")
*/
public function EditFormulare(ValidatorInterface $validator, Request $request, SecurityService $securityService, FormsService $formsService, AssignService $assignService)
{
$team = $this->getUser()->getTeam();
$forms = $this->getDoctrine()->getRepository(Forms::class)->find($request->get('id'));

if ($securityService->teamDataCheck($forms, $team) === false) {
return $this->redirectToRoute('forms');
}

$newForms = $formsService->cloneForms($forms, $this->getUser());
$form = $formsService->createForm($newForms, $team);
$form->handleRequest($request);
$assign = $assignService->createForm($forms, $team);

$errors = array();
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$forms->setActiv(false);
$forms->setStatus(4);
$newForms = $form->getData();

$errors = $validator->validate($newForms);
if (count($errors) == 0) {

$em->persist($newForms);
$em->persist($forms);
$em->flush();
return $this->redirectToRoute('forms_edit', array('id' => $newForms->getId(), 'snack' => 'Erfolgreich gespeichert'));
}
}
return $this->render('forms/edit.html.twig', [
'form' => $form->createView(),
'assignForm' => $assign->createView(),
'errors' => $errors,
'title' => 'Formular bearbeiten',
'daten' => $forms,
'activ' => $forms->getActiv(),
'snack' => $request->get('snack')
]);
}

/**
* @Route("/forms/download/{id}", name="forms_download_file", methods={"GET"})
* @ParamConverter("forms", options={"mapping"={"id"="id"}})
*/
public function downloadArticleReference(FilesystemInterface $internFileSystem, Forms $forms, SecurityService $securityService)
{

$stream = $internFileSystem->read($forms->getUpload());

$team = $this->getUser()->getTeam();
if ($securityService->teamDataCheck($forms, $team) === false) {
return $this->redirectToRoute('dashboard');
}

$type = $internFileSystem->getMimetype($forms->getUpload());
$response = new Response($stream);
$response->headers->set('Content-Type', $type);
$disposition = HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT,
preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $forms->getUpload())
);

$response->headers->set('Content-Disposition', $disposition);
return $response;
}
}
Loading

0 comments on commit 0bac745

Please sign in to comment.