src/Controller/App/ChildController.php line 43
<?php
namespace App\Controller\App;
use App\Entity\User;
use App\Form\PostType;
use DateTime;
use App\Entity\Child;
use App\Entity\Post;
use App\Form\ChildType;
use App\Entity\Location;
use App\Entity\Pointing;
use App\Entity\Classroom;
use App\Entity\FamilyMember;
use App\Entity\Subscription;
use App\Form\ChildTypeBasic;
use App\Service\FileUploader;
use App\Form\ChildOverviewType;
use App\Form\PointingEditNoteType;
use App\Form\SubscriptionTypeBasic;
use App\Repository\ChildRepository;
use App\Repository\PointingRepository;
use Doctrine\ORM\EntityManagerInterface;
use Endroid\QrCode\Builder\BuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
#[Route('/app/child')]
class ChildController extends AbstractController
{
public function __construct(private TranslatorInterface $translator)
{
}
#[Route('/', name: 'app_child_index', methods: ['GET', 'POST'])]
public function index(Request $request, ChildRepository $childRepository, FileUploader $fileUploader): Response
{
if ($request->isXmlHttpRequest()) {
if ($this->isCsrfTokenValid('child_type_basic', $_POST['child_type_basic']['_token'])) {
$child = new Child();
$form = $this->createForm(ChildTypeBasic::class, $child);
$address = new Location();
$address->setCountry('DZ');
$address->setWilaya('Boumerdès');
$child->setAddress($address);
$child
->setFirstName($_POST['child_type_basic']['first_name'])
->setLastName($_POST['child_type_basic']['last_name'])
->setGender($_POST['child_type_basic']['gender'])
->setBirthDate(new DateTime($_POST['child_type_basic']['birth_date']))
->setBirthPlace($_POST['child_type_basic']['birth_place'])
->setBlood($_POST['child_type_basic']['blood']);
$form->handleRequest($request);
$photo = $form->get('photo')->getData();
if ($photo) {
$uploadedFileName = $fileUploader->upload($photo, 'children_dir');
$child->setPhoto($uploadedFileName);
}
$childRepository->add($child, true);
return new JsonResponse(['status' => 'ok', 'data' => $child->getId(), 'msg' => $this->translator->trans('Enfant crée !')]);
} else {
return new JsonResponse(['status' => 'no', 'data' => null, 'msg' => $this->translator->trans('token invalid !')]);
}
}
$child = new Child();
$address = new Location();
$address->setCountry('DZ');
$address->setWilaya('Boumerdès');
$child->setAddress($address);
$form = $this->createForm(ChildTypeBasic::class, $child);
$edit_form = $this->createForm(ChildTypeBasic::class, $child, [
'action' => $this->generateUrl('app_child_edit_ajax', ['id' => '1']),
'method' => 'POST',
'attr' => ['name' => 'child_type_basic_edit']
]);
return $this->render('app/child/index.html.twig', [
'children' => $childRepository->findAll(),
'form' => $form->createView(),
'edit_form' => $edit_form->createView(),
]);
}
#[Route('/new', name: 'app_child_new', methods: ['GET', 'POST'])]
public function new(Request $request, ChildRepository $childRepository, FileUploader $fileUploader): Response
{
return $this->redirectToRoute('app_child_index', [], Response::HTTP_SEE_OTHER);
// $child = new Child();
// $address = new Location();
// $address->setCountry('DZ');
// $address->setWilaya('Boumerdès');
// $child->setAddress($address);
// $form = $this->createForm(ChildType::class, $child);
// $form->handleRequest($request);
// if ($form->isSubmitted() && $form->isValid()) {
// $photo = $form->get('photo')->getData();
// if ($photo) {
// $uploadedFileName = $fileUploader->upload($photo, 'children_dir');
// $child->setPhoto($uploadedFileName);
// }
// $childRepository->add($child, true);
// $this->addFlash('success', $this->translator->trans('Succès !!'));
// return $this->redirectToRoute('app_child_index', [], Response::HTTP_SEE_OTHER);
// }
// return $this->renderForm('app/child/new.html.twig', [
// 'child' => $child,
// 'form' => $form,
// ]);
}
#[Route('/search', name: 'app_child_search', methods: ['GET'])]
public function search(Request $request, SerializerInterface $serializer, ChildRepository $childRepository): Response
{
$query = $request->query->get('term');
$children = $childRepository->search($query);
$result = [
'children' => $children,
];
$json = $serializer->serialize($result, 'json', []);
return $this->json(json_decode($json));
}
#[Route('/{id}', name: 'app_child_show', methods: ['GET'])]
public function qrcode(Child $child, EntityManagerInterface $manager): Response
{
$subscription = new Subscription();
$subscription->setChild($child);
$form_new_subscription = $this->createForm(SubscriptionTypeBasic::class, $subscription, [
'action' => $this->generateUrl('app_subscription_index', []),
'method' => 'POST'
]);
$pointing = new Pointing();
// $pointing->setChild($child);
// $form_new_pointing = $this->createForm(PointingType::class, $pointing, [
// 'action' => $this->generateUrl('app_pointing_index', []),
// 'method' => 'POST'
// ]);
$edit_poiting_note_form = $this->createForm(PointingEditNoteType::class, $pointing, [
'action' => $this->generateUrl('app_pointing_index', []),
'method' => 'POST'
]);
$all_classrooms = $manager->getRepository(Classroom::class)->findAll();
$all_familymembers = $manager->getRepository(FamilyMember::class)->findAll();
$overview_form = $this->createForm(ChildOverviewType::class, $child, [
'action' => $this->generateUrl('app_child_edit', ['id' => $child->getId()]),
'method' => 'POST',
'attr' => ['name' => 'child_overview_type_edit']
]);
$activity_form = $this->createForm(PostType::class);
return $this->render('app/child/show.html.twig', [
'child' => $child,
'form_new_subscription' => $form_new_subscription->createView(),
'edit_poiting_note_form' => $edit_poiting_note_form->createView(),
'all_classrooms' => $all_classrooms,
'all_familymembers' => $all_familymembers,
'overview_form' => $overview_form->createView(),
'activity_form' => $activity_form->createView(),
]);
}
#[Route('/{id}/qrcode', name: 'app_child_show_qrcode', methods: ['GET'])]
public function show(Child $child, BuilderInterface $customQrCodeBuilder): Response
{
$result = $customQrCodeBuilder
->data($child->getId())
->labelText('AMGHAR')
->size(512)
->margin(20)
->build();
$response = new Response();
$filename = $child->getLastName() . ' ' . $child->getFirstName() . '.svg';
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', 'image/svg+xml');
$response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '";');
// $response->headers->set('Content-length', strlen($result->getString()));
$response->sendHeaders();
$response->setContent($result->getString());
return $response;
}
#[Route('/ajax/{id}', name: 'app_child_show_ajax', methods: ['GET'])]
public function show_ajax(Child $child, SerializerInterface $serializer): Response
{
$json = $serializer->serialize($child, 'json', ['groups' => ['read:child:basic', 'read:section:basic']]);
return $this->json(json_decode($json));
// return $this->redirectToRoute('app_child_index', [], Response::HTTP_SEE_OTHER);
}
#[Route('/{id}/edit', name: 'app_child_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Child $child, ChildRepository $childRepository, FileUploader $fileUploader): Response
{
$form = $this->createForm(ChildType::class, $child);
$form->handleRequest($request);
$overview_form = $this->createForm(ChildOverviewType::class, $child);
$overview_form->handleRequest($request);
if ($overview_form->isSubmitted() && $overview_form->isValid()) {
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès !!'));
return $this->redirectToRoute('app_child_show', ['id' => $child->getId()], Response::HTTP_SEE_OTHER);
}
if ($form->isSubmitted() && $form->isValid()) {
$photo = $form->get('photo')->getData();
if ($photo) {
$uploadedFileName = $fileUploader->upload($photo, 'children_dir');
$child->setPhoto($uploadedFileName);
}
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès'));
return $this->redirectToRoute('app_child_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('app/child/edit.html.twig', [
'child' => $child,
'form' => $form,
]);
}
#[Route('/{id?}/edit/ajax', name: 'app_child_edit_ajax', methods: ['GET', 'POST'])]
public function edit_ajax(Request $request, Child $child, ChildRepository $childRepository, FileUploader $fileUploader, EntityManagerInterface $manager): Response
{
if ($request->isXmlHttpRequest()) {
if ($this->isCsrfTokenValid('edit_child', $_POST['child_type_basic']['_token'])) {
$form = $this->createForm(ChildTypeBasic::class, $child);
$child
->setFirstName($_POST['child_type_basic']['first_name'])
->setLastName($_POST['child_type_basic']['last_name'])
->setGender($_POST['child_type_basic']['gender'])
->setBirthDate(new DateTime($_POST['child_type_basic']['birth_date']))
->setBirthPlace($_POST['child_type_basic']['birth_place'])
->setBlood($_POST['child_type_basic']['blood']);
$form->handleRequest($request);
$photo = $form->get('photo')->getData();
if ($photo) {
$uploadedFileName = $fileUploader->upload($photo, 'children_dir');
$child->setPhoto($uploadedFileName);
}
$childRepository->add($child, true);
return new JsonResponse(['status' => 'ok', 'data' => $child->getId(), 'msg' => $this->translator->trans('Enfant mis à jour !')]);
} else {
return new JsonResponse(['status' => 'no', 'data' => null, 'msg' => $this->translator->trans('token invalid !')]);
}
}
}
#[Route('/{id}', name: 'app_child_delete', methods: ['POST'])]
public function delete(Request $request, Child $child, ChildRepository $childRepository): Response
{
if ($this->isCsrfTokenValid('delete' . $child->getId(), $request->request->get('_token'))) {
try {
$childRepository->remove($child, true);
$this->addFlash('success', $this->translator->trans('Succès!!'));
} catch (\Exception $e) {
$errorMessage = $e->getMessage();
$result = explode(':', $errorMessage);
$this->addFlash('error', $result[0]);
}
}
return $this->redirectToRoute('app_child_index', [], Response::HTTP_SEE_OTHER);
}
#[Route('/assign/classroom/{classroom}/{child}', name: 'app_child_assign_classroom', methods: ['GET'])]
public function assign_classroom(Child $child, Classroom $classroom, ChildRepository $childRepository): Response
{
$child->addClassroom($classroom);
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès !!'));
return $this->redirectToRoute('app_child_show', ['id' => $child->getId()], Response::HTTP_SEE_OTHER);
}
#[Route('/unassign/classroom/{classroom}/{child}', name: 'app_child_unassign_classroom', methods: ['GET'])]
public function unassign_classroom(Child $child, Classroom $classroom, ChildRepository $childRepository): Response
{
$child->removeClassroom($classroom);
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès !!'));
return $this->redirectToRoute('app_child_show', ['id' => $child->getId()], Response::HTTP_SEE_OTHER);
}
#[Route('/assign/family/member/{member}/{child}', name: 'app_child_assign_member', methods: ['GET'])]
public function assign_member(Child $child, FamilyMember $member, ChildRepository $childRepository): Response
{
$child->addFamily($member);
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès !!'));
return $this->redirectToRoute('app_child_show', ['id' => $child->getId()], Response::HTTP_SEE_OTHER);
}
#[Route('/unassign/family/member/{member}/{child}', name: 'app_child_unassign_member', methods: ['GET'])]
public function unassign_member(Child $child, FamilyMember $member, ChildRepository $childRepository): Response
{
$child->removeFamily($member);
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès !!'));
return $this->redirectToRoute('app_child_show', ['id' => $child->getId()], Response::HTTP_SEE_OTHER);
}
#[Route('/export/csv', name: 'app_child_export_csv', methods: ['GET'])]
public function export_csv(ChildRepository $childRepository, NormalizerInterface $normalizer, SerializerInterface $serializer): Response
{
$children = $childRepository->findAll();
$csv = $serializer->serialize($children, 'csv', ['groups' => ['read:child:export', 'read:section:export']]);
$csv = str_replace('first_name', 'Prénom', $csv);
$csv = str_replace('last_name', 'Nom', $csv);
$csv = str_replace('gender', 'Genre', $csv);
$csv = str_replace('birth_date', 'Date de naissance', $csv);
$csv = str_replace('birth_place', 'Lieu de naissance', $csv);
$csv = str_replace('blood', 'Groupe sanguin', $csv);
// id,,,,,,,diseases,allergies,food_habit,behavior,fears,interests,description,section,section.id,section.name,section.description,section.age_range ◀
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="e-rawdha-children-' . date('m-d-Y') . '.csv"');
header("Pragma: no-cache");
header("Expires: 0");
return new Response($csv);
}
#[Route('/{id}/check_in', name: 'app_child_check_in', methods: ['GET'])]
public function check_in(Child $child, ChildRepository $childRepository, PointingRepository $pointingRepository): Response
{
$pointings = $pointingRepository->findToday();
if (count($pointings) > 0) {
$pointing = $pointings[count($pointings) - 1];
if (!$pointing->getCheckOut()) {
$pointing->setCheckIn(new DateTime())
->setCreatedBy($this->getUser());
} else {
$pointing = new Pointing();
$pointing->setCheckIn(new DateTime())
->setCreatedBy($this->getUser());
}
} else {
$pointing = new Pointing();
$pointing->setCheckIn(new DateTime())
->setCreatedBy($this->getUser());
}
$child->addPointing($pointing);
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès !!'));
return $this->redirectToRoute('app_child_index', [], Response::HTTP_SEE_OTHER);
}
#[Route('/{id}/check_out', name: 'app_child_check_out', methods: ['GET'])]
public function check_out(Child $child, ChildRepository $childRepository, PointingRepository $pointingRepository): Response
{
$pointings = $pointingRepository->findToday();
if (count($pointings) > 0) {
$pointing = $pointings[count($pointings) - 1];
$pointing->setCheckOut(new DateTime())
->setCreatedBy($this->getUser());
} else {
$pointing = new Pointing();
$pointing->setCheckIn(new DateTime())
->setCheckOut(new DateTime())
->setCreatedBy($this->getUser());
}
$childRepository->add($child, true);
$this->addFlash('success', $this->translator->trans('Succès !!'));
return $this->redirectToRoute('app_child_index', [], Response::HTTP_SEE_OTHER);
}
#[Route('/registration/certificate', name: 'app_child_registration_certificate', methods: ['GET', 'POST'])]
public function certificate_of_subscription(ChildRepository $childRepository): Response
{
/** @var User */
$user = $this->getUser();
$child = $childRepository->find($_POST['child_registration_certificate']['id']);
$company = $user->getCompany();
try {
$path_logo = 'uploads/companies/' . $company->getLogo();
$type = pathinfo($path_logo, PATHINFO_EXTENSION);
$data = file_get_contents($path_logo);
$logo = 'data:image/' . $type . ';base64,' . base64_encode($data);
} catch (\Throwable $th) {
$logo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAAAXNSR0IArs4c6QAACy1JREFUeF7t3HmojF0YAPBnbBeXLjdRky3GEpGQJP4g+5pStmRP1uxbIoV/pCwJJbtsEZItW8qWyRJZMsZ6b0jXenFF8/UcZr6Za+7Mu5zzvmd53vq6y3veszzP73vOeef7CITD4Vh+fj7k5OQAXRQBtxEoKSmBoqIiCESj0Rh+EwqFIC8vz22/9LzBEfj06RNEIhHAQhUoKCiI5ebmsl8QLoNVuFx6HBUaKi4u/gMrGAxC8g2qXC6jbNjjpe0UFhb+DwtjQbgME8FhuenM/AOLcHGItEFdlFWI0sIiXAbJcLHUTLtbmbAIl4uIG/BotiNTRliEywAhDpaYDRV2mRUW4XIQeY0fsYLKMizCpbEUG0uzisoWLMJlIwMaNrWDyjYswqWhGAtLsovKESzCZSETGjVxgsoxLMKlkZwMS3GKyhUswqU3LjeoXMMiXHricouKCyzCpRcuHqi4wSJceuDihYorLMKlN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+vjxY/ZZFf5T+nrx4gU7g2F143XhJ+t44Sfu8fNdvG90g5/2I158O43vevgmGQiHwzH8Jn5I4zUh6sfMCOBHGgjuP5BRt3+pT5M0AAAAAElFTkSuQmCC';
}
$child_place_of_birth = $_POST['child_registration_certificate']['child_place_of_birth'] !== '' ? $_POST['child_registration_certificate']['child_place_of_birth'] : $child->getBirthPlace();
$child_start_date = DateTime::createFromFormat('d/m/Y', $_POST['child_registration_certificate']['child_start_date']);
$child_end_date = null;
if (!array_key_exists('to_this_day', $_POST['child_registration_certificate'])) {
$child_end_date = DateTime::createFromFormat('Y-m-d', $_POST['child_registration_certificate']['child_end_date']);
}
return $this->render('app/child/pdf-registration-certificat.html.twig', [
'company' => $company,
'manager' => $_POST['child_registration_certificate']['manager'],
'child' => $child,
'child_name' => $child->getFirstName() . ' ' . $child->getLastName(),
'start_date' => new DateTime(),
'child_place_of_birth' => $child_place_of_birth,
'child_start_date' => $child_start_date,
'child_end_date' => $child_end_date,
'qrcode' => $child->getId(),
'logo' => $logo,
]);
}
}