| @@ -82,6 +82,8 @@ | |||||
| <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/symfony/twig-bridge" /> | <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/symfony/twig-bridge" /> | ||||
| <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/symfony/translation-contracts" /> | <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/symfony/translation-contracts" /> | ||||
| <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/twig/twig" /> | <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/twig/twig" /> | ||||
| <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/nelmio/cors-bundle" /> | |||||
| <excludeFolder url="file://$MODULE_DIR$/httpdocs/vendor/symfony/expression-language" /> | |||||
| </content> | </content> | ||||
| <orderEntry type="inheritedJdk" /> | <orderEntry type="inheritedJdk" /> | ||||
| <orderEntry type="sourceFolder" forTests="false" /> | <orderEntry type="sourceFolder" forTests="false" /> | ||||
| @@ -1,2 +1,4 @@ | |||||
| # spt-crm-backend | # spt-crm-backend | ||||
| - password generation: bin/console security:hash-password | |||||
| - annotations to attributes: https://www.doctrine-project.org/2022/11/04/annotations-to-attributes.html | |||||
| @@ -1,4 +1,4 @@ | |||||
| /.idea | |||||
| ###> symfony/framework-bundle ### | ###> symfony/framework-bundle ### | ||||
| /.env.local | /.env.local | ||||
| /.env.local.php | /.env.local.php | ||||
| @@ -12,10 +12,12 @@ | |||||
| "doctrine/doctrine-migrations-bundle": "^3.2", | "doctrine/doctrine-migrations-bundle": "^3.2", | ||||
| "doctrine/orm": "^2.15", | "doctrine/orm": "^2.15", | ||||
| "dompdf/dompdf": "*", | "dompdf/dompdf": "*", | ||||
| "nelmio/cors-bundle": "^2.3", | |||||
| "phpoffice/phpspreadsheet": "*", | "phpoffice/phpspreadsheet": "*", | ||||
| "sensio/framework-extra-bundle": "*", | "sensio/framework-extra-bundle": "*", | ||||
| "symfony/console": "6.2.*", | "symfony/console": "6.2.*", | ||||
| "symfony/dotenv": "6.2.*", | "symfony/dotenv": "6.2.*", | ||||
| "symfony/expression-language": "6.2.*", | |||||
| "symfony/flex": "^2", | "symfony/flex": "^2", | ||||
| "symfony/framework-bundle": "6.2.*", | "symfony/framework-bundle": "6.2.*", | ||||
| "symfony/mailer": "6.2.*", | "symfony/mailer": "6.2.*", | ||||
| @@ -4,7 +4,7 @@ | |||||
| "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||||
| "This file is @generated automatically" | "This file is @generated automatically" | ||||
| ], | ], | ||||
| "content-hash": "15a7bf65293c8d623f82986b5c017838", | |||||
| "content-hash": "6009e6bfd2cb0c417acb9969128399f7", | |||||
| "packages": [ | "packages": [ | ||||
| { | { | ||||
| "name": "doctrine/annotations", | "name": "doctrine/annotations", | ||||
| @@ -1896,6 +1896,68 @@ | |||||
| ], | ], | ||||
| "time": "2022-08-04T09:53:51+00:00" | "time": "2022-08-04T09:53:51+00:00" | ||||
| }, | }, | ||||
| { | |||||
| "name": "nelmio/cors-bundle", | |||||
| "version": "2.3.1", | |||||
| "source": { | |||||
| "type": "git", | |||||
| "url": "https://github.com/nelmio/NelmioCorsBundle.git", | |||||
| "reference": "185d2c0ae50a3f0b628790170164d5f1c5b7c281" | |||||
| }, | |||||
| "dist": { | |||||
| "type": "zip", | |||||
| "url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/185d2c0ae50a3f0b628790170164d5f1c5b7c281", | |||||
| "reference": "185d2c0ae50a3f0b628790170164d5f1c5b7c281", | |||||
| "shasum": "" | |||||
| }, | |||||
| "require": { | |||||
| "psr/log": "^1.0 || ^2.0 || ^3.0", | |||||
| "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0" | |||||
| }, | |||||
| "require-dev": { | |||||
| "mockery/mockery": "^1.2", | |||||
| "symfony/phpunit-bridge": "^4.4 || ^5.4 || ^6.0" | |||||
| }, | |||||
| "type": "symfony-bundle", | |||||
| "extra": { | |||||
| "branch-alias": { | |||||
| "dev-master": "2.x-dev" | |||||
| } | |||||
| }, | |||||
| "autoload": { | |||||
| "psr-4": { | |||||
| "Nelmio\\CorsBundle\\": "" | |||||
| }, | |||||
| "exclude-from-classmap": [ | |||||
| "/Tests/" | |||||
| ] | |||||
| }, | |||||
| "notification-url": "https://packagist.org/downloads/", | |||||
| "license": [ | |||||
| "MIT" | |||||
| ], | |||||
| "authors": [ | |||||
| { | |||||
| "name": "Nelmio", | |||||
| "homepage": "http://nelm.io" | |||||
| }, | |||||
| { | |||||
| "name": "Symfony Community", | |||||
| "homepage": "https://github.com/nelmio/NelmioCorsBundle/contributors" | |||||
| } | |||||
| ], | |||||
| "description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application", | |||||
| "keywords": [ | |||||
| "api", | |||||
| "cors", | |||||
| "crossdomain" | |||||
| ], | |||||
| "support": { | |||||
| "issues": "https://github.com/nelmio/NelmioCorsBundle/issues", | |||||
| "source": "https://github.com/nelmio/NelmioCorsBundle/tree/2.3.1" | |||||
| }, | |||||
| "time": "2023-02-16T08:49:29+00:00" | |||||
| }, | |||||
| { | { | ||||
| "name": "phenx/php-font-lib", | "name": "phenx/php-font-lib", | ||||
| "version": "0.5.4", | "version": "0.5.4", | ||||
| @@ -3559,6 +3621,69 @@ | |||||
| ], | ], | ||||
| "time": "2023-03-01T10:32:47+00:00" | "time": "2023-03-01T10:32:47+00:00" | ||||
| }, | }, | ||||
| { | |||||
| "name": "symfony/expression-language", | |||||
| "version": "v6.2.7", | |||||
| "source": { | |||||
| "type": "git", | |||||
| "url": "https://github.com/symfony/expression-language.git", | |||||
| "reference": "83e1fee4c018aa60bcbbecd585a2c54af6aca905" | |||||
| }, | |||||
| "dist": { | |||||
| "type": "zip", | |||||
| "url": "https://api.github.com/repos/symfony/expression-language/zipball/83e1fee4c018aa60bcbbecd585a2c54af6aca905", | |||||
| "reference": "83e1fee4c018aa60bcbbecd585a2c54af6aca905", | |||||
| "shasum": "" | |||||
| }, | |||||
| "require": { | |||||
| "php": ">=8.1", | |||||
| "symfony/cache": "^5.4|^6.0", | |||||
| "symfony/service-contracts": "^1.1|^2|^3" | |||||
| }, | |||||
| "type": "library", | |||||
| "autoload": { | |||||
| "psr-4": { | |||||
| "Symfony\\Component\\ExpressionLanguage\\": "" | |||||
| }, | |||||
| "exclude-from-classmap": [ | |||||
| "/Tests/" | |||||
| ] | |||||
| }, | |||||
| "notification-url": "https://packagist.org/downloads/", | |||||
| "license": [ | |||||
| "MIT" | |||||
| ], | |||||
| "authors": [ | |||||
| { | |||||
| "name": "Fabien Potencier", | |||||
| "email": "fabien@symfony.com" | |||||
| }, | |||||
| { | |||||
| "name": "Symfony Community", | |||||
| "homepage": "https://symfony.com/contributors" | |||||
| } | |||||
| ], | |||||
| "description": "Provides an engine that can compile and evaluate expressions", | |||||
| "homepage": "https://symfony.com", | |||||
| "support": { | |||||
| "source": "https://github.com/symfony/expression-language/tree/v6.2.7" | |||||
| }, | |||||
| "funding": [ | |||||
| { | |||||
| "url": "https://symfony.com/sponsor", | |||||
| "type": "custom" | |||||
| }, | |||||
| { | |||||
| "url": "https://github.com/fabpot", | |||||
| "type": "github" | |||||
| }, | |||||
| { | |||||
| "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", | |||||
| "type": "tidelift" | |||||
| } | |||||
| ], | |||||
| "time": "2023-02-16T09:57:23+00:00" | |||||
| }, | |||||
| { | { | ||||
| "name": "symfony/filesystem", | "name": "symfony/filesystem", | ||||
| "version": "v6.2.10", | "version": "v6.2.10", | ||||
| @@ -7,4 +7,5 @@ return [ | |||||
| Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], | Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], | ||||
| Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], | Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], | ||||
| Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], | Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], | ||||
| Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], | |||||
| ]; | ]; | ||||
| @@ -0,0 +1,13 @@ | |||||
| nelmio_cors: | |||||
| defaults: | |||||
| allow_credentials: true | |||||
| origin_regex: true | |||||
| allow_origin: [ '*' ] | |||||
| allow_headers: [ '*' ] | |||||
| # allow_origin: ['%env(CORS_ALLOW_ORIGIN)%'] | |||||
| allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] | |||||
| # allow_headers: ['Content-Type', 'Authorization'] | |||||
| expose_headers: ['Link'] | |||||
| max_age: 3600 | |||||
| paths: | |||||
| '^/': null | |||||
| @@ -7,16 +7,19 @@ security: | |||||
| users_in_memory: { memory: null } | users_in_memory: { memory: null } | ||||
| app_entity_users: | app_entity_users: | ||||
| entity: | entity: | ||||
| class: App\Entity\EntUser | |||||
| class: App\Entity\User | |||||
| property: email | |||||
| firewalls: | firewalls: | ||||
| dev: | dev: | ||||
| pattern: ^/(_(profiler|wdt)|css|images|js)/ | pattern: ^/(_(profiler|wdt)|css|images|js)/ | ||||
| security: false | security: false | ||||
| main: | main: | ||||
| lazy: true | lazy: true | ||||
| provider: users_in_memory | |||||
| #provider: app_entity_users | |||||
| custom_authenticators: | custom_authenticators: | ||||
| - App\Security\JsonAuthenticator | - App\Security\JsonAuthenticator | ||||
| logout: | |||||
| path: security_logout | |||||
| # activate different ways to authenticate | # activate different ways to authenticate | ||||
| # https://symfony.com/doc/current/security.html#the-firewall | # https://symfony.com/doc/current/security.html#the-firewall | ||||
| @@ -2,12 +2,12 @@ | |||||
| namespace App\Command; | namespace App\Command; | ||||
| use App\Entity\EntCustomer; | |||||
| use App\Entity\EntCustomerMeeting; | |||||
| use App\Entity\EntCustomerMeetingParticipant; | |||||
| use App\Entity\EntInternalMeeting; | |||||
| use App\Entity\EntInternalMeetingParticipant; | |||||
| use App\Entity\EntUser; | |||||
| use App\Entity\Customer; | |||||
| use App\Entity\CustomerMeeting; | |||||
| use App\Entity\CustomerMeetingParticipant; | |||||
| use App\Entity\InternalMeeting; | |||||
| use App\Entity\InternalMeetingParticipant; | |||||
| use App\Entity\User; | |||||
| use App\Utils\Utils; | use App\Utils\Utils; | ||||
| use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
| use Doctrine\ORM\Query; | use Doctrine\ORM\Query; | ||||
| @@ -60,8 +60,8 @@ class CmdSendReminderEmails extends Command | |||||
| { | { | ||||
| Utils::sendMail($this->mailer, 'test', 'd.knudsen@spawntree.de', 'this is a test', $this->environment); | Utils::sendMail($this->mailer, 'test', 'd.knudsen@spawntree.de', 'this is a test', $this->environment); | ||||
| $usersById = Utils::getSortedObjectsById($this->em->getRepository(EntUser::class)->findAll()); | |||||
| $customersById = Utils::getSortedObjectsById($this->em->getRepository(EntCustomer::class)->findAll()); | |||||
| $usersById = Utils::getSortedObjectsById($this->em->getRepository(User::class)->findAll()); | |||||
| $customersById = Utils::getSortedObjectsById($this->em->getRepository(Customer::class)->findAll()); | |||||
| $now = (new \DateTime())->format("Y-m-d H:i:s"); | $now = (new \DateTime())->format("Y-m-d H:i:s"); | ||||
| $checkStartDay = (new \DateTime())->modify('+2 day')->format("Y-m-d H:i:s"); | $checkStartDay = (new \DateTime())->modify('+2 day')->format("Y-m-d H:i:s"); | ||||
| @@ -137,22 +137,22 @@ class CmdSendReminderEmails extends Command | |||||
| protected function sendCustomerReminder($meetings, $customersById, $usersById, $firstReminder) | protected function sendCustomerReminder($meetings, $customersById, $usersById, $firstReminder) | ||||
| { | { | ||||
| /** @var EntCustomerMeeting $meeting */ | |||||
| /** @var CustomerMeeting $meeting */ | |||||
| foreach ($meetings as $meeting) { | foreach ($meetings as $meeting) { | ||||
| /** @var EntUser $owner */ | |||||
| /** @var User $owner */ | |||||
| $owner = $usersById[$meeting->getOwnerUserId()]; | $owner = $usersById[$meeting->getOwnerUserId()]; | ||||
| /** @var EntCustomer $customer */ | |||||
| /** @var Customer $customer */ | |||||
| $customer = $customersById[$meeting->getCustomerId()]; | $customer = $customersById[$meeting->getCustomerId()]; | ||||
| $participantsByUserId = Utils::getSortedObjects('getParticipantUserId', | $participantsByUserId = Utils::getSortedObjects('getParticipantUserId', | ||||
| $this->em->getRepository('App:EntCustomerMeetingParticipant')->findBy(['customer_meeting_id' => $meeting->getId()])); | |||||
| $this->em->getRepository(CustomerMeetingParticipant::class)->findBy(['customer_meeting_id' => $meeting->getId()])); | |||||
| $subject = "Termin-Erinnerung: ". $customer->getName(). " ".$meeting->getStartDate()->format('d.m.Y H:i'); | $subject = "Termin-Erinnerung: ". $customer->getName(). " ".$meeting->getStartDate()->format('d.m.Y H:i'); | ||||
| $body = $this->createCustomerMeetingReminderEmailBody($meeting, $subject, $customer, $owner, $participantsByUserId, $usersById); | $body = $this->createCustomerMeetingReminderEmailBody($meeting, $subject, $customer, $owner, $participantsByUserId, $usersById); | ||||
| Utils::sendMail($this->mailer, $subject, $owner->getEmail(), $body, $this->environment); | Utils::sendMail($this->mailer, $subject, $owner->getEmail(), $body, $this->environment); | ||||
| /*** @var EntCustomerMeetingParticipant $participant */ | |||||
| /*** @var CustomerMeetingParticipant $participant */ | |||||
| foreach ($participantsByUserId as $userId => $participant) { | foreach ($participantsByUserId as $userId => $participant) { | ||||
| /** @var EntUser $pUser */ | |||||
| /** @var User $pUser */ | |||||
| $pUser = $usersById[$participant->getParticipantUserId()]; | $pUser = $usersById[$participant->getParticipantUserId()]; | ||||
| Utils::sendMail($this->mailer, $subject, $pUser->getEmail(), $body, $this->environment); | Utils::sendMail($this->mailer, $subject, $pUser->getEmail(), $body, $this->environment); | ||||
| } | } | ||||
| @@ -165,20 +165,20 @@ class CmdSendReminderEmails extends Command | |||||
| protected function sendInternalReminder($meetings, $usersById, $firstReminder) | protected function sendInternalReminder($meetings, $usersById, $firstReminder) | ||||
| { | { | ||||
| /** @var EntInternalMeeting $meeting */ | |||||
| /** @var InternalMeeting $meeting */ | |||||
| foreach ($meetings as $meeting) { | foreach ($meetings as $meeting) { | ||||
| /** @var EntUser $owner */ | |||||
| /** @var User $owner */ | |||||
| $owner = $usersById[$meeting->getOwnerUserId()]; | $owner = $usersById[$meeting->getOwnerUserId()]; | ||||
| $participantsByUserId = Utils::getSortedObjects('getParticipantUserId', | $participantsByUserId = Utils::getSortedObjects('getParticipantUserId', | ||||
| $this->em->getRepository('App:EntInternalMeetingParticipant')->findBy(['internal_meeting_id' => $meeting->getId()])); | |||||
| $this->em->getRepository(InternalMeetingParticipant::class)->findBy(['internal_meeting_id' => $meeting->getId()])); | |||||
| $subject = "Termin-Erinnerung: PLP intern ".$meeting->getStartDate()->format('d.m.Y H:i'); | $subject = "Termin-Erinnerung: PLP intern ".$meeting->getStartDate()->format('d.m.Y H:i'); | ||||
| $body = $this->createInternalMeetingReminderEmailBody($meeting, $subject, $owner, $participantsByUserId, $usersById); | $body = $this->createInternalMeetingReminderEmailBody($meeting, $subject, $owner, $participantsByUserId, $usersById); | ||||
| Utils::sendMail($this->mailer, $subject, $owner->getEmail(), $body, $this->environment); | Utils::sendMail($this->mailer, $subject, $owner->getEmail(), $body, $this->environment); | ||||
| /*** @var EntInternalMeetingParticipant $participant */ | |||||
| /*** @var InternalMeetingParticipant $participant */ | |||||
| foreach ($participantsByUserId as $userId => $participant) { | foreach ($participantsByUserId as $userId => $participant) { | ||||
| /** @var EntUser $pUser */ | |||||
| /** @var User $pUser */ | |||||
| $pUser = $usersById[$participant->getParticipantUserId()]; | $pUser = $usersById[$participant->getParticipantUserId()]; | ||||
| Utils::sendMail($this->mailer, $subject, $pUser->getEmail(), $body, $this->environment); | Utils::sendMail($this->mailer, $subject, $pUser->getEmail(), $body, $this->environment); | ||||
| } | } | ||||
| @@ -189,7 +189,7 @@ class CmdSendReminderEmails extends Command | |||||
| } | } | ||||
| } | } | ||||
| protected function createCustomerMeetingReminderEmailBody(EntCustomerMeeting $meeting, $subject, EntCustomer $customer, EntUser $owner, $participantsByUserId, $usersById) | |||||
| protected function createCustomerMeetingReminderEmailBody(CustomerMeeting $meeting, $subject, Customer $customer, User $owner, $participantsByUserId, $usersById) | |||||
| { | { | ||||
| $body = $subject." </br>"; | $body = $subject." </br>"; | ||||
| $body.= "Kunde: ".$customer->getName()."</br>"; | $body.= "Kunde: ".$customer->getName()."</br>"; | ||||
| @@ -217,14 +217,14 @@ class CmdSendReminderEmails extends Command | |||||
| $body.= "Options-Termin: ".($meeting->getIsOptionMeeting() ? "ja" : "nein")."</br></br>"; | $body.= "Options-Termin: ".($meeting->getIsOptionMeeting() ? "ja" : "nein")."</br></br>"; | ||||
| $body.= "Interne Teilnehmer: </br>"; | $body.= "Interne Teilnehmer: </br>"; | ||||
| foreach ($participantsByUserId as $pUserId => $item) { | foreach ($participantsByUserId as $pUserId => $item) { | ||||
| /** @var EntUser $participant */ | |||||
| /** @var User $participant */ | |||||
| $participant = $usersById[$pUserId]; | $participant = $usersById[$pUserId]; | ||||
| $body.= $participant->getFirstname(). " ". $participant->getLastname(). "</br>"; | $body.= $participant->getFirstname(). " ". $participant->getLastname(). "</br>"; | ||||
| } | } | ||||
| return $body; | return $body; | ||||
| } | } | ||||
| protected function createInternalMeetingReminderEmailBody(EntInternalMeeting $meeting, $subject, EntUser $owner, $participantsByUserId, $usersById) | |||||
| protected function createInternalMeetingReminderEmailBody(InternalMeeting $meeting, $subject, User $owner, $participantsByUserId, $usersById) | |||||
| { | { | ||||
| $body = $subject." </br>"; | $body = $subject." </br>"; | ||||
| $body.= "Betreff: ".$meeting->getTitle()."</br>"; | $body.= "Betreff: ".$meeting->getTitle()."</br>"; | ||||
| @@ -234,7 +234,7 @@ class CmdSendReminderEmails extends Command | |||||
| $body.= "Bemerkung: ".$meeting->getDescription()."</br>"; | $body.= "Bemerkung: ".$meeting->getDescription()."</br>"; | ||||
| $body.= "Interne Teilnehmer: </br>"; | $body.= "Interne Teilnehmer: </br>"; | ||||
| foreach ($participantsByUserId as $pUserId => $item) { | foreach ($participantsByUserId as $pUserId => $item) { | ||||
| /** @var EntUser $participant */ | |||||
| /** @var User $participant */ | |||||
| $participant = $usersById[$pUserId]; | $participant = $usersById[$pUserId]; | ||||
| $body.= $participant->getFirstname(). " ". $participant->getLastname(). "</br>"; | $body.= $participant->getFirstname(). " ". $participant->getLastname(). "</br>"; | ||||
| } | } | ||||
| @@ -243,11 +243,11 @@ class CmdSendReminderEmails extends Command | |||||
| protected function sendCustomerMeetingReportReminder($meetings, $customersById, $usersById) | protected function sendCustomerMeetingReportReminder($meetings, $customersById, $usersById) | ||||
| { | { | ||||
| /** @var EntCustomerMeeting $meeting */ | |||||
| /** @var CustomerMeeting $meeting */ | |||||
| foreach ($meetings as $meeting) { | foreach ($meetings as $meeting) { | ||||
| /** @var EntUser $owner */ | |||||
| /** @var User $owner */ | |||||
| $owner = $usersById[$meeting->getOwnerUserId()]; | $owner = $usersById[$meeting->getOwnerUserId()]; | ||||
| /** @var EntCustomer $customer */ | |||||
| /** @var Customer $customer */ | |||||
| $customer = $customersById[$meeting->getCustomerId()]; | $customer = $customersById[$meeting->getCustomerId()]; | ||||
| $subject = "Termin-Report-Erinnerung (Kundentermin) ". $customer->getName(); | $subject = "Termin-Report-Erinnerung (Kundentermin) ". $customer->getName(); | ||||
| @@ -262,9 +262,9 @@ class CmdSendReminderEmails extends Command | |||||
| protected function sendInternalMeetingReportReminder($meetings, $usersById) | protected function sendInternalMeetingReportReminder($meetings, $usersById) | ||||
| { | { | ||||
| /** @var EntInternalMeeting $meeting */ | |||||
| /** @var InternalMeeting $meeting */ | |||||
| foreach ($meetings as $meeting) { | foreach ($meetings as $meeting) { | ||||
| /** @var EntUser $owner */ | |||||
| /** @var User $owner */ | |||||
| $owner = $usersById[$meeting->getOwnerUserId()]; | $owner = $usersById[$meeting->getOwnerUserId()]; | ||||
| $subject = "Termin-Report-Erinnerung (PLP intern)"; | $subject = "Termin-Report-Erinnerung (PLP intern)"; | ||||
| @@ -277,7 +277,7 @@ class CmdSendReminderEmails extends Command | |||||
| } | } | ||||
| } | } | ||||
| protected function createReportReminderEmailBody($meeting, $subject, EntUser $owner) | |||||
| protected function createReportReminderEmailBody($meeting, $subject, User $owner) | |||||
| { | { | ||||
| $body = $subject." </br>"; | $body = $subject." </br>"; | ||||
| $body.= "Für folgenden Termin wurde bisher noch kein Report angelegt.</br>"; | $body.= "Für folgenden Termin wurde bisher noch kein Report angelegt.</br>"; | ||||
| @@ -7,8 +7,9 @@ | |||||
| */ | */ | ||||
| namespace App\Controller; | namespace App\Controller; | ||||
| use App\Entity\EntCountry; | |||||
| use App\Entity\Country; | |||||
| use App\Utils\Reply; | use App\Utils\Reply; | ||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Dompdf\Dompdf; | use Dompdf\Dompdf; | ||||
| use Dompdf\Options; | use Dompdf\Options; | ||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||||
| @@ -22,17 +23,18 @@ class AdminController extends AbstractController | |||||
| { | { | ||||
| const XMAS_CONTACT_PDF_TYPE_CUSTOMER = 'customer'; | const XMAS_CONTACT_PDF_TYPE_CUSTOMER = 'customer'; | ||||
| public function __construct(private EntityManagerInterface $em) {} | |||||
| #[Route('/create-xmas-pdf', name: 'create_xmas_pdf')] | #[Route('/create-xmas-pdf', name: 'create_xmas_pdf')] | ||||
| public function createXmasPdf(Request $request) | public function createXmasPdf(Request $request) | ||||
| { | { | ||||
| $type = $request->request->get('type'); | $type = $request->request->get('type'); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| $entityCache = []; | $entityCache = []; | ||||
| switch ($type) { | switch ($type) { | ||||
| case self::XMAS_CONTACT_PDF_TYPE_CUSTOMER: | case self::XMAS_CONTACT_PDF_TYPE_CUSTOMER: | ||||
| $sql = "SELECT cc.*, c.name AS company FROM customer_contact cc, customer c WHERE cc.is_xmas_mail_recipient = 1 AND cc.customer_id = c.id ORDER BY cc.lastname ASC"; | $sql = "SELECT cc.*, c.name AS company FROM customer_contact cc, customer c WHERE cc.is_xmas_mail_recipient = 1 AND cc.customer_id = c.id ORDER BY cc.lastname ASC"; | ||||
| $statement = $em->getConnection()->prepare($sql); | |||||
| $statement = $this->em->getConnection()->prepare($sql); | |||||
| $statement->execute(); | $statement->execute(); | ||||
| $entries = $statement->fetchAll(); | $entries = $statement->fetchAll(); | ||||
| break; | break; | ||||
| @@ -45,8 +47,8 @@ class AdminController extends AbstractController | |||||
| $cacheKey = trim($entry['firstname'].$entry['lastname'].$entry['street'].$entry['street_no'].$entry['zip'].$entry['city']); | $cacheKey = trim($entry['firstname'].$entry['lastname'].$entry['street'].$entry['street_no'].$entry['zip'].$entry['city']); | ||||
| if (!array_key_exists($cacheKey, $entityCache)) { | if (!array_key_exists($cacheKey, $entityCache)) { | ||||
| $entityCache[$cacheKey] = 1; | $entityCache[$cacheKey] = 1; | ||||
| /** @var EntCountry $entCountry */ | |||||
| $entCountry = !is_null($entry['country_id']) ? EntCountry::getCountryById($em, $entry['country_id']) : null; | |||||
| /** @var Country $entCountry */ | |||||
| $entCountry = !is_null($entry['country_id']) ? Country::getCountryById($this->em, $entry['country_id']) : null; | |||||
| $data[] = [ | $data[] = [ | ||||
| 'company' => $entry['company'], | 'company' => $entry['company'], | ||||
| 'firstname' => $entry['firstname'], | 'firstname' => $entry['firstname'], | ||||
| @@ -7,17 +7,18 @@ | |||||
| */ | */ | ||||
| namespace App\Controller; | namespace App\Controller; | ||||
| use App\Entity\EntCustomer; | |||||
| use App\Entity\EntCustomerContact; | |||||
| use App\Entity\EntCustomerMeeting; | |||||
| use App\Entity\EntCustomerMeetingParticipant; | |||||
| use App\Entity\EntCustomerNote; | |||||
| use App\Entity\EntMeetingType; | |||||
| use App\Entity\EntUser; | |||||
| use App\Entity\Customer; | |||||
| use App\Entity\CustomerContact; | |||||
| use App\Entity\CustomerMeeting; | |||||
| use App\Entity\CustomerMeetingParticipant; | |||||
| use App\Entity\CustomerNote; | |||||
| use App\Entity\MeetingType; | |||||
| use App\Entity\User; | |||||
| use App\EntityVirtual\ServiceData; | use App\EntityVirtual\ServiceData; | ||||
| use App\Utils\Message; | use App\Utils\Message; | ||||
| use App\Utils\Reply; | use App\Utils\Reply; | ||||
| use App\Utils\Utils; | use App\Utils\Utils; | ||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; | ||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
| @@ -29,18 +30,19 @@ use Symfony\Component\Routing\Annotation\Route; | |||||
| #[Security("is_granted('ROLE_ADMIN')")] | #[Security("is_granted('ROLE_ADMIN')")] | ||||
| class CustomerEditController extends AbstractController | class CustomerEditController extends AbstractController | ||||
| { | { | ||||
| public function __construct(private EntityManagerInterface $em) {} | |||||
| #[Route('/create-customer', name: 'create_customer')] | #[Route('/create-customer', name: 'create_customer')] | ||||
| public function createCustomer(Request $request) | public function createCustomer(Request $request) | ||||
| { | { | ||||
| $customerClient = json_decode($request->request->get('customer')); | $customerClient = json_decode($request->request->get('customer')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = new EntCustomer($em, $customerClient->name); | |||||
| $entCustomer->setClientData($em, $customerClient); | |||||
| $em->persist($entCustomer); | |||||
| $em->flush(); | |||||
| $fullMappedCustomer = $entCustomer->clientMapper($em, true); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = new Customer($this->em, $customerClient->name); | |||||
| $entCustomer->setClientData($this->em, $customerClient); | |||||
| $this->em->persist($entCustomer); | |||||
| $this->em->flush(); | |||||
| $fullMappedCustomer = $entCustomer->clientMapper($this->em, true); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMERS, ServiceData::ACTION_ADD, $fullMappedCustomer); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMERS, ServiceData::ACTION_ADD, $fullMappedCustomer); | ||||
| return Reply::getResponse($fullMappedCustomer, Message::SUCCESS_CUSTOMER_CREATE, 0, $serviceData); | return Reply::getResponse($fullMappedCustomer, Message::SUCCESS_CUSTOMER_CREATE, 0, $serviceData); | ||||
| @@ -50,17 +52,16 @@ class CustomerEditController extends AbstractController | |||||
| public function editCustomer(Request $request) | public function editCustomer(Request $request) | ||||
| { | { | ||||
| $customerClient = json_decode($request->request->get('customer')); | $customerClient = json_decode($request->request->get('customer')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($customerClient->id); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($customerClient->id); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $entCustomer->setClientData($em, $customerClient); | |||||
| $em->persist($entCustomer); | |||||
| $em->flush(); | |||||
| $entCustomer->setClientData($this->em, $customerClient); | |||||
| $this->em->persist($entCustomer); | |||||
| $this->em->flush(); | |||||
| $fullMappedCustomer = $entCustomer->clientMapper($em, true); | |||||
| $fullMappedCustomer = $entCustomer->clientMapper($this->em, true); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMERS, ServiceData::ACTION_EDIT, $fullMappedCustomer); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMERS, ServiceData::ACTION_EDIT, $fullMappedCustomer); | ||||
| return Reply::getResponse($fullMappedCustomer, Message::SUCCESS_CUSTOMER_EDIT, 0, $serviceData); | return Reply::getResponse($fullMappedCustomer, Message::SUCCESS_CUSTOMER_EDIT, 0, $serviceData); | ||||
| @@ -70,158 +71,152 @@ class CustomerEditController extends AbstractController | |||||
| public function createCustomerContact(Request $request) | public function createCustomerContact(Request $request) | ||||
| { | { | ||||
| $customerContactClient = json_decode($request->request->get('customerContact')); | $customerContactClient = json_decode($request->request->get('customerContact')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($customerContactClient->customer_id); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository('App:Customer')->find($customerContactClient->customer_id); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntCustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = new EntCustomerContact($em, $entCustomer, $customerContactClient->lastname); | |||||
| $entCustomerContact->setClientData($em, $customerContactClient); | |||||
| $em->persist($entCustomerContact); | |||||
| $em->flush(); | |||||
| /** @var CustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = new CustomerContact($this->em, $entCustomer, $customerContactClient->lastname); | |||||
| $entCustomerContact->setClientData($this->em, $customerContactClient); | |||||
| $this->em->persist($entCustomerContact); | |||||
| $this->em->flush(); | |||||
| $fullMappedCustomerContact = $entCustomerContact->clientMapper($em, true); | |||||
| $fullMappedCustomerContact = $entCustomerContact->clientMapper($this->em, true); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_CONTACTS, ServiceData::ACTION_ADD, $fullMappedCustomerContact); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_CONTACTS, ServiceData::ACTION_ADD, $fullMappedCustomerContact); | ||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_CONTACT_CREATE, 0, $serviceData); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_CONTACT_CREATE, 0, $serviceData); | |||||
| } | } | ||||
| #[Route('/edit-customer-contact', name: 'edit_customer_contact')] | #[Route('/edit-customer-contact', name: 'edit_customer_contact')] | ||||
| public function editCustomerContact(Request $request) | public function editCustomerContact(Request $request) | ||||
| { | { | ||||
| $customerContactClient = json_decode($request->request->get('customerContact')); | $customerContactClient = json_decode($request->request->get('customerContact')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntCustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $em->getRepository('App:EntCustomerContact')->find($customerContactClient->id); | |||||
| /** @var CustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $this->em->getRepository(CustomerContact::class)->find($customerContactClient->id); | |||||
| if (is_null($entCustomerContact)) { | if (is_null($entCustomerContact)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | ||||
| } | } | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($entCustomerContact->getCustomerId()); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($entCustomerContact->getCustomerId()); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $entCustomerContact->setClientData($em, $customerContactClient); | |||||
| $em->persist($entCustomerContact); | |||||
| $em->flush(); | |||||
| $entCustomerContact->setClientData($this->em, $customerContactClient); | |||||
| $this->em->persist($entCustomerContact); | |||||
| $this->em->flush(); | |||||
| $fullMappedCustomerContact = $entCustomerContact->clientMapper($em, true); | |||||
| $fullMappedCustomerContact = $entCustomerContact->clientMapper($this->em, true); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_CONTACTS, ServiceData::ACTION_EDIT, $fullMappedCustomerContact); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_CONTACTS, ServiceData::ACTION_EDIT, $fullMappedCustomerContact); | ||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_CONTACT_EDIT, 0, $serviceData); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_CONTACT_EDIT, 0, $serviceData); | |||||
| } | } | ||||
| #[Route('/delete-customer-contact', name: 'delete_customer_contact')] | #[Route('/delete-customer-contact', name: 'delete_customer_contact')] | ||||
| public function deleteCustomerContact(Request $request) | public function deleteCustomerContact(Request $request) | ||||
| { | { | ||||
| $customerContactIdClient = json_decode($request->request->get('customerContactId')); | $customerContactIdClient = json_decode($request->request->get('customerContactId')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntCustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $em->getRepository('App:EntCustomerContact')->find($customerContactIdClient); | |||||
| /** @var CustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $this->em->getRepository(CustomerContact::class)->find($customerContactIdClient); | |||||
| if (is_null($entCustomerContact)) { | if (is_null($entCustomerContact)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | ||||
| } | } | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($entCustomerContact->getCustomerId()); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($entCustomerContact->getCustomerId()); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $fullMappedCustomerContact = $entCustomerContact->clientMapper($em, true); | |||||
| $em->remove($entCustomerContact); | |||||
| $em->flush(); | |||||
| $fullMappedCustomerContact = $entCustomerContact->clientMapper($this->em, true); | |||||
| $this->em->remove($entCustomerContact); | |||||
| $this->em->flush(); | |||||
| $sql = "UPDATE `customer_meeting` SET `customer_contact_id` = NULL WHERE `customer_contact_id` = ". $customerContactIdClient; | $sql = "UPDATE `customer_meeting` SET `customer_contact_id` = NULL WHERE `customer_contact_id` = ". $customerContactIdClient; | ||||
| $statement = $em->getConnection()->prepare($sql); | |||||
| $statement = $this->em->getConnection()->prepare($sql); | |||||
| $statement->execute(); | $statement->execute(); | ||||
| $sql = "UPDATE `customer_note` SET `customer_contact_id` = NULL WHERE `customer_contact_id` = ". $customerContactIdClient; | $sql = "UPDATE `customer_note` SET `customer_contact_id` = NULL WHERE `customer_contact_id` = ". $customerContactIdClient; | ||||
| $statement = $em->getConnection()->prepare($sql); | |||||
| $statement = $this->em->getConnection()->prepare($sql); | |||||
| $statement->execute(); | $statement->execute(); | ||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_CONTACTS, ServiceData::ACTION_DELETE, $fullMappedCustomerContact); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_CONTACTS, ServiceData::ACTION_DELETE, $fullMappedCustomerContact); | ||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_CONTACT_DELETE, 0, $serviceData); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_CONTACT_DELETE, 0, $serviceData); | |||||
| } | } | ||||
| #[Route('/create-customer-note', name: 'create_customer_note')] | #[Route('/create-customer-note', name: 'create_customer_note')] | ||||
| public function createCustomerNote(Request $request) | public function createCustomerNote(Request $request) | ||||
| { | { | ||||
| $customerNoteClient = json_decode($request->request->get('customerNote')); | $customerNoteClient = json_decode($request->request->get('customerNote')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($customerNoteClient->customer_id); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($customerNoteClient->customer_id); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntCustomerNote $entCustomerNote */ | |||||
| $entCustomerNote = new EntCustomerNote($em, $entCustomer, $user, $customerNoteClient->title); | |||||
| $entCustomerNote->setClientData($em, $customerNoteClient); | |||||
| $em->persist($entCustomerNote); | |||||
| $em->flush(); | |||||
| /** @var CustomerNote $entCustomerNote */ | |||||
| $entCustomerNote = new CustomerNote($this->em, $entCustomer, $user, $customerNoteClient->title); | |||||
| $entCustomerNote->setClientData($this->em, $customerNoteClient); | |||||
| $this->em->persist($entCustomerNote); | |||||
| $this->em->flush(); | |||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_NOTE_CREATE); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_NOTE_CREATE); | |||||
| } | } | ||||
| #[Route('/edit-customer-note', name: 'edit_customer_note')] | #[Route('/edit-customer-note', name: 'edit_customer_note')] | ||||
| public function editCustomerNote(Request $request) | public function editCustomerNote(Request $request) | ||||
| { | { | ||||
| $customerNoteClient = json_decode($request->request->get('customerNote')); | $customerNoteClient = json_decode($request->request->get('customerNote')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomerNote $entCustomerNote */ | |||||
| $entCustomerNote = $em->getRepository(EntCustomerNote::class)->find($customerNoteClient->id); | |||||
| /** @var CustomerNote $entCustomerNote */ | |||||
| $entCustomerNote = $this->em->getRepository(CustomerNote::class)->find($customerNoteClient->id); | |||||
| $bHasRightsToEdit = $entCustomerNote->getCreationUserId() == $user->getId() || $user->isAdmin(); | $bHasRightsToEdit = $entCustomerNote->getCreationUserId() == $user->getId() || $user->isAdmin(); | ||||
| if (is_null($entCustomerNote) || !$bHasRightsToEdit) { | if (is_null($entCustomerNote) || !$bHasRightsToEdit) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository(EntCustomer::class)->find($entCustomerNote->getCustomerId()); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($entCustomerNote->getCustomerId()); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $entCustomerNote->setClientData($em, $customerNoteClient); | |||||
| $em->persist($entCustomerNote); | |||||
| $em->flush(); | |||||
| $entCustomerNote->setClientData($this->em, $customerNoteClient); | |||||
| $this->em->persist($entCustomerNote); | |||||
| $this->em->flush(); | |||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_NOTE_EDIT); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_NOTE_EDIT); | |||||
| } | } | ||||
| #[Route('/delete-customer-note', name: 'delete_customer_note')] | #[Route('/delete-customer-note', name: 'delete_customer_note')] | ||||
| public function deleteCustomerNote(Request $request) | public function deleteCustomerNote(Request $request) | ||||
| { | { | ||||
| $customerNoteIdClient = json_decode($request->request->get('customerNoteId')); | $customerNoteIdClient = json_decode($request->request->get('customerNoteId')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomerNote $entCustomerNote */ | |||||
| $entCustomerNote = $em->getRepository('App:EntCustomerNote')->find($customerNoteIdClient); | |||||
| /** @var CustomerNote $entCustomerNote */ | |||||
| $entCustomerNote = $this->em->getRepository(CustomerNote::class)->find($customerNoteIdClient); | |||||
| $bHasRightsToDelete = $entCustomerNote->getCreationUserId() == $user->getId() || $user->isAdmin(); | $bHasRightsToDelete = $entCustomerNote->getCreationUserId() == $user->getId() || $user->isAdmin(); | ||||
| if (is_null($entCustomerNote) || !$bHasRightsToDelete) { | if (is_null($entCustomerNote) || !$bHasRightsToDelete) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($entCustomerNote->getCustomerId()); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($entCustomerNote->getCustomerId()); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $em->remove($entCustomerNote); | |||||
| $em->flush(); | |||||
| $this->em->remove($entCustomerNote); | |||||
| $this->em->flush(); | |||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_NOTE_DELETE); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_NOTE_DELETE); | |||||
| } | } | ||||
| } | } | ||||
| @@ -7,15 +7,16 @@ | |||||
| */ | */ | ||||
| namespace App\Controller; | namespace App\Controller; | ||||
| use App\Entity\EntCustomer; | |||||
| use App\Entity\EntCustomerMeeting; | |||||
| use App\Entity\EntCustomerMeetingParticipant; | |||||
| use App\Entity\EntMeetingType; | |||||
| use App\Entity\EntUser; | |||||
| use App\Entity\Customer; | |||||
| use App\Entity\CustomerMeeting; | |||||
| use App\Entity\CustomerMeetingParticipant; | |||||
| use App\Entity\MeetingType; | |||||
| use App\Entity\User; | |||||
| use App\EntityVirtual\ServiceData; | use App\EntityVirtual\ServiceData; | ||||
| use App\Utils\Message; | use App\Utils\Message; | ||||
| use App\Utils\Reply; | use App\Utils\Reply; | ||||
| use App\Utils\Utils; | use App\Utils\Utils; | ||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; | ||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
| @@ -27,55 +28,56 @@ use Symfony\Component\Routing\Annotation\Route; | |||||
| #[Security("is_granted('ROLE_ADMIN') and is_granted('ROLE_SALES')")] | #[Security("is_granted('ROLE_ADMIN') and is_granted('ROLE_SALES')")] | ||||
| class CustomerMeetingEditController extends AbstractController | class CustomerMeetingEditController extends AbstractController | ||||
| { | { | ||||
| public function __construct(private EntityManagerInterface $em) {} | |||||
| #[Route('/create-customer-meeting', name: 'create_customer_meeting')] | #[Route('/create-customer-meeting', name: 'create_customer_meeting')] | ||||
| public function createCustomerMeeting(Request $request) | public function createCustomerMeeting(Request $request) | ||||
| { | { | ||||
| $customerMeetingClient = json_decode($request->request->get('customerMeeting')); | $customerMeetingClient = json_decode($request->request->get('customerMeeting')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository(EntCustomer::class)->find($customerMeetingClient->customer_id); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($customerMeetingClient->customer_id); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntUser $entOwnerUser */ | |||||
| $entOwnerUser = $em->getRepository(EntUser::class)->find($customerMeetingClient->owner_user_id); | |||||
| /** @var User $entOwnerUser */ | |||||
| $entOwnerUser = $this->em->getRepository(User::class)->find($customerMeetingClient->owner_user_id); | |||||
| if (is_null($entOwnerUser)) { | if (is_null($entOwnerUser)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntMeetingType $entMeetingType */ | |||||
| $entMeetingType = $em->getRepository(EntMeetingType::class)->find($customerMeetingClient->meeting_type_id); | |||||
| /** @var MeetingType $entMeetingType */ | |||||
| $entMeetingType = $this->em->getRepository(MeetingType::class)->find($customerMeetingClient->meeting_type_id); | |||||
| if (is_null($entMeetingType)) { | if (is_null($entMeetingType)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| // Database manipulation in transaction | // Database manipulation in transaction | ||||
| $dbCon = $this->getDoctrine()->getConnection(); | |||||
| $dbCon = $this->em->getConnection(); | |||||
| $dbCon->beginTransaction(); | $dbCon->beginTransaction(); | ||||
| try { | try { | ||||
| /** @var EntCustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = new EntCustomerMeeting($em, $entCustomer, $user, $entOwnerUser, $entMeetingType, $customerMeetingClient->is_option_meeting, | |||||
| /** @var CustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = new CustomerMeeting($this->em, $entCustomer, $user, $entOwnerUser, $entMeetingType, $customerMeetingClient->is_option_meeting, | |||||
| $customerMeetingClient->title, $customerMeetingClient->start_date, $customerMeetingClient->end_date); | $customerMeetingClient->title, $customerMeetingClient->start_date, $customerMeetingClient->end_date); | ||||
| $entCustomerMeeting->setClientData($em, $customerMeetingClient); | |||||
| $em->persist($entCustomerMeeting); | |||||
| $em->flush(); | |||||
| $entCustomerMeeting->setClientData($this->em, $customerMeetingClient); | |||||
| $this->em->persist($entCustomerMeeting); | |||||
| $this->em->flush(); | |||||
| $cntParticipants = count($customerMeetingClient->v_participants); | $cntParticipants = count($customerMeetingClient->v_participants); | ||||
| for ($i = 0; $i < $cntParticipants; $i++) { | for ($i = 0; $i < $cntParticipants; $i++) { | ||||
| /** @var EntUser $participantUser */ | |||||
| $participantUser = $em->getRepository('App:EntUser')->find($customerMeetingClient->v_participants[$i]->participant_user_id); | |||||
| /** @var User $participantUser */ | |||||
| $participantUser = $this->em->getRepository(User::class)->find($customerMeetingClient->v_participants[$i]->participant_user_id); | |||||
| if (is_null($participantUser)) { | if (is_null($participantUser)) { | ||||
| throw new Exception('invalid participant user'); | throw new Exception('invalid participant user'); | ||||
| } | } | ||||
| /** @var EntCustomerMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new EntCustomerMeetingParticipant($em, $entCustomerMeeting, $participantUser); | |||||
| $em->persist($entParticipant); | |||||
| /** @var CustomerMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new CustomerMeetingParticipant($this->em, $entCustomerMeeting, $participantUser); | |||||
| $this->em->persist($entParticipant); | |||||
| } | } | ||||
| $em->flush(); | |||||
| $this->em->flush(); | |||||
| } catch (Exception $e) { | } catch (Exception $e) { | ||||
| return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | ||||
| @@ -84,37 +86,36 @@ class CustomerMeetingEditController extends AbstractController | |||||
| $dbCon->commit(); | $dbCon->commit(); | ||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_ADD, $entCustomerMeeting->clientMapper($em, true)); | |||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_MEETING_CREATE, 0, $serviceData); | |||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_ADD, $entCustomerMeeting->clientMapper($this->em, true)); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_MEETING_CREATE, 0, $serviceData); | |||||
| } | } | ||||
| #[Route('/edit-customer-meeting', name: 'edit_customer_meeting')] | #[Route('/edit-customer-meeting', name: 'edit_customer_meeting')] | ||||
| public function editCustomerMeeting(Request $request) | public function editCustomerMeeting(Request $request) | ||||
| { | { | ||||
| $customerMeetingClient = json_decode($request->request->get('customerMeeting')); | $customerMeetingClient = json_decode($request->request->get('customerMeeting')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($customerMeetingClient->customer_id); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($customerMeetingClient->customer_id); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntUser $entOwnerUser */ | |||||
| $entOwnerUser = $em->getRepository('App:EntUser')->find($customerMeetingClient->owner_user_id); | |||||
| /** @var User $entOwnerUser */ | |||||
| $entOwnerUser = $this->em->getRepository(User::class)->find($customerMeetingClient->owner_user_id); | |||||
| if (is_null($entOwnerUser)) { | if (is_null($entOwnerUser)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntMeetingType $entMeetingType */ | |||||
| $entMeetingType = $em->getRepository('App:EntMeetingType')->find($customerMeetingClient->meeting_type_id); | |||||
| /** @var MeetingType $entMeetingType */ | |||||
| $entMeetingType = $this->em->getRepository(MeetingType::class)->find($customerMeetingClient->meeting_type_id); | |||||
| if (is_null($entMeetingType)) { | if (is_null($entMeetingType)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntCustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $em->getRepository('App:EntCustomerMeeting')->find($customerMeetingClient->id); | |||||
| /** @var CustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $this->em->getRepository(CustomerMeeting::class)->find($customerMeetingClient->id); | |||||
| if (is_null($entCustomerMeeting)) { | if (is_null($entCustomerMeeting)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | ||||
| } | } | ||||
| @@ -132,41 +133,41 @@ class CustomerMeetingEditController extends AbstractController | |||||
| } | } | ||||
| // Database manipulation in transaction | // Database manipulation in transaction | ||||
| $dbCon = $this->getDoctrine()->getConnection(); | |||||
| $dbCon = $this->em->getConnection(); | |||||
| $dbCon->beginTransaction(); | $dbCon->beginTransaction(); | ||||
| try { | try { | ||||
| $entCustomerMeeting->setClientData($em, $customerMeetingClient); | |||||
| $em->persist($entCustomerMeeting); | |||||
| $em->flush(); | |||||
| $entCustomerMeeting->setClientData($this->em, $customerMeetingClient); | |||||
| $this->em->persist($entCustomerMeeting); | |||||
| $this->em->flush(); | |||||
| $formerParticipantsByUserId = Utils::getSortedObjects('getParticipantUserId', | $formerParticipantsByUserId = Utils::getSortedObjects('getParticipantUserId', | ||||
| $em->getRepository('App:EntCustomerMeetingParticipant')->findBy(['customer_meeting_id' => $entCustomerMeeting->getId()])); | |||||
| $this->em->getRepository(CustomerMeetingParticipant::class)->findBy(['customer_meeting_id' => $entCustomerMeeting->getId()])); | |||||
| $pUserIdsToKeep = []; | $pUserIdsToKeep = []; | ||||
| $cntParticipants = count($customerMeetingClient->v_participants); | $cntParticipants = count($customerMeetingClient->v_participants); | ||||
| for ($i = 0; $i < $cntParticipants; $i++) { | for ($i = 0; $i < $cntParticipants; $i++) { | ||||
| if (!array_key_exists($customerMeetingClient->v_participants[$i]->participant_user_id, $formerParticipantsByUserId)) { | if (!array_key_exists($customerMeetingClient->v_participants[$i]->participant_user_id, $formerParticipantsByUserId)) { | ||||
| /** @var EntUser $participantUser */ | |||||
| $participantUser = $em->getRepository('App:EntUser')->find($customerMeetingClient->v_participants[$i]->participant_user_id); | |||||
| /** @var User $participantUser */ | |||||
| $participantUser = $this->em->getRepository(User::class)->find($customerMeetingClient->v_participants[$i]->participant_user_id); | |||||
| if (is_null($participantUser)) { | if (is_null($participantUser)) { | ||||
| throw new Exception('invalid participant user'); | throw new Exception('invalid participant user'); | ||||
| } | } | ||||
| /** @var EntCustomerMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new EntCustomerMeetingParticipant($em, $entCustomerMeeting, $participantUser); | |||||
| $em->persist($entParticipant); | |||||
| /** @var CustomerMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new CustomerMeetingParticipant($this->em, $entCustomerMeeting, $participantUser); | |||||
| $this->em->persist($entParticipant); | |||||
| } else { | } else { | ||||
| $pUserIdsToKeep[$customerMeetingClient->v_participants[$i]->participant_user_id] = 1; | $pUserIdsToKeep[$customerMeetingClient->v_participants[$i]->participant_user_id] = 1; | ||||
| } | } | ||||
| } | } | ||||
| /** @var EntCustomerMeetingParticipant $formerParticipant */ | |||||
| /** @var CustomerMeetingParticipant $formerParticipant */ | |||||
| foreach ($formerParticipantsByUserId as $pUserId => $formerParticipant) { | foreach ($formerParticipantsByUserId as $pUserId => $formerParticipant) { | ||||
| if (!array_key_exists($pUserId, $pUserIdsToKeep)) { | if (!array_key_exists($pUserId, $pUserIdsToKeep)) { | ||||
| $em->remove($formerParticipant); | |||||
| $this->em->remove($formerParticipant); | |||||
| } | } | ||||
| } | } | ||||
| $em->flush(); | |||||
| $this->em->flush(); | |||||
| } catch (Exception $e) { | } catch (Exception $e) { | ||||
| return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | ||||
| @@ -174,20 +175,19 @@ class CustomerMeetingEditController extends AbstractController | |||||
| // All data stored correctly | // All data stored correctly | ||||
| $dbCon->commit(); | $dbCon->commit(); | ||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_EDIT, $entCustomerMeeting->clientMapper($em, true)); | |||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_MEETING_EDIT, 0, $serviceData); | |||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_EDIT, $entCustomerMeeting->clientMapper($this->em, true)); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_MEETING_EDIT, 0, $serviceData); | |||||
| } | } | ||||
| #[Route('/delete-customer-meeting', name: 'delete_customer_meeting')] | #[Route('/delete-customer-meeting', name: 'delete_customer_meeting')] | ||||
| public function deleteCustomerMeeting(Request $request) | public function deleteCustomerMeeting(Request $request) | ||||
| { | { | ||||
| $customerMeetingIdClient = json_decode($request->request->get('customerMeetingId')); | $customerMeetingIdClient = json_decode($request->request->get('customerMeetingId')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $em->getRepository('App:EntCustomerMeeting')->find($customerMeetingIdClient); | |||||
| /** @var CustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $this->em->getRepository(CustomerMeeting::class)->find($customerMeetingIdClient); | |||||
| if (is_null($entCustomerMeeting)) { | if (is_null($entCustomerMeeting)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | ||||
| } | } | ||||
| @@ -204,36 +204,35 @@ class CustomerMeetingEditController extends AbstractController | |||||
| return Reply::getErrorResponse(Message::ERROR_MEETING_NOT_EDIT_DELETABLE); | return Reply::getErrorResponse(Message::ERROR_MEETING_NOT_EDIT_DELETABLE); | ||||
| } | } | ||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($entCustomerMeeting->getCustomerId()); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($entCustomerMeeting->getCustomerId()); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $mappedCustomerMeeting = $entCustomerMeeting->clientMapper($em, true); | |||||
| $em->remove($entCustomerMeeting); | |||||
| $mappedCustomerMeeting = $entCustomerMeeting->clientMapper($this->em, true); | |||||
| $this->em->remove($entCustomerMeeting); | |||||
| $participants = $em->getRepository('App:EntCustomerMeetingParticipant')->findBy(['customer_meeting_id' => $entCustomerMeeting->getId()]); | |||||
| /** @var EntCustomerMeetingParticipant $participant */ | |||||
| $participants = $this->em->getRepository(CustomerMeetingParticipant::class)->findBy(['customer_meeting_id' => $entCustomerMeeting->getId()]); | |||||
| /** @var CustomerMeetingParticipant $participant */ | |||||
| foreach ($participants as $participant) { | foreach ($participants as $participant) { | ||||
| $em->remove($participant); | |||||
| $this->em->remove($participant); | |||||
| } | } | ||||
| $em->flush(); | |||||
| $this->em->flush(); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_DELETE, $mappedCustomerMeeting); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_DELETE, $mappedCustomerMeeting); | ||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_MEETING_DELETE, 0, $serviceData); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_MEETING_DELETE, 0, $serviceData); | |||||
| } | } | ||||
| #[Route('/check-customer-meeting-report', name: 'check_customer_meeting_report')] | #[Route('/check-customer-meeting-report', name: 'check_customer_meeting_report')] | ||||
| public function checkCustomerMeetingReport(Request $request) | public function checkCustomerMeetingReport(Request $request) | ||||
| { | { | ||||
| $customerMeetingIdClient = json_decode($request->request->get('customerMeetingId')); | $customerMeetingIdClient = json_decode($request->request->get('customerMeetingId')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $em->getRepository('App:EntCustomerMeeting')->find($customerMeetingIdClient); | |||||
| /** @var CustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $this->em->getRepository(CustomerMeeting::class)->find($customerMeetingIdClient); | |||||
| $bHasRightsToMakeReport = | $bHasRightsToMakeReport = | ||||
| $entCustomerMeeting->getCreationUserId() == $user->getId() || | $entCustomerMeeting->getCreationUserId() == $user->getId() || | ||||
| $entCustomerMeeting->getOwnerUserId() == $user->getId() || | $entCustomerMeeting->getOwnerUserId() == $user->getId() || | ||||
| @@ -251,13 +250,12 @@ class CustomerMeetingEditController extends AbstractController | |||||
| { | { | ||||
| $customerMeetingIdClient = json_decode($request->request->get('customerMeetingId')); | $customerMeetingIdClient = json_decode($request->request->get('customerMeetingId')); | ||||
| $customerMeetingReportClient = json_decode($request->request->get('customerMeetingReport')); | $customerMeetingReportClient = json_decode($request->request->get('customerMeetingReport')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntCustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $em->getRepository('App:EntCustomerMeeting')->find($customerMeetingIdClient); | |||||
| /** @var CustomerMeeting $entCustomerMeeting */ | |||||
| $entCustomerMeeting = $this->em->getRepository(CustomerMeeting::class)->find($customerMeetingIdClient); | |||||
| $bHasRightsToMakeReport = | $bHasRightsToMakeReport = | ||||
| $entCustomerMeeting->getOwnerUserId() == $user->getId() || | $entCustomerMeeting->getOwnerUserId() == $user->getId() || | ||||
| $user->isAdmin(); | $user->isAdmin(); | ||||
| @@ -265,17 +263,17 @@ class CustomerMeetingEditController extends AbstractController | |||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($entCustomerMeeting->getCustomerId()); | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($entCustomerMeeting->getCustomerId()); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| $entCustomerMeeting->setReport($customerMeetingReportClient); | $entCustomerMeeting->setReport($customerMeetingReportClient); | ||||
| $em->persist($entCustomerMeeting); | |||||
| $em->flush(); | |||||
| $this->em->persist($entCustomerMeeting); | |||||
| $this->em->flush(); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_EDIT, $entCustomerMeeting->clientMapper($em, true)); | |||||
| return Reply::getResponse($entCustomer->clientMapper($em, true), Message::SUCCESS_CUSTOMER_MEETING_REPORT_SET, 0, $serviceData); | |||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_CUSTOMER_MEETINGS, ServiceData::ACTION_EDIT, $entCustomerMeeting->clientMapper($this->em, true)); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true), Message::SUCCESS_CUSTOMER_MEETING_REPORT_SET, 0, $serviceData); | |||||
| } | } | ||||
| } | } | ||||
| @@ -7,10 +7,13 @@ | |||||
| */ | */ | ||||
| namespace App\Controller; | namespace App\Controller; | ||||
| use App\Entity\EntCustomer; | |||||
| use App\Entity\Customer; | |||||
| use App\Entity\CustomerContact; | |||||
| use App\Entity\CustomerMeeting; | |||||
| use App\Utils\Message; | use App\Utils\Message; | ||||
| use App\Utils\Reply; | use App\Utils\Reply; | ||||
| use App\Utils\Utils; | use App\Utils\Utils; | ||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
| use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
| @@ -19,15 +22,16 @@ use Symfony\Component\Routing\Annotation\Route; | |||||
| #[Security("is_granted('ROLE_USER')")] | #[Security("is_granted('ROLE_USER')")] | ||||
| class CustomerViewController extends AbstractController | class CustomerViewController extends AbstractController | ||||
| { | { | ||||
| public function __construct(private EntityManagerInterface $em) {} | |||||
| #[Route('/get-customer-data', name: 'get_customer_data')] | #[Route('/get-customer-data', name: 'get_customer_data')] | ||||
| public function getCustomerData() | public function getCustomerData() | ||||
| { | { | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| return Reply::getResponse( | return Reply::getResponse( | ||||
| [ | [ | ||||
| 'customers' => Utils::clientMap($em, $em->getRepository('App:EntCustomer')->findAll()), | |||||
| 'customerContacts' => Utils::clientMap($em, $em->getRepository('App:EntCustomerContact')->findAll()), | |||||
| 'customerMeetings' => Utils::clientMap($em, $em->getRepository('App:EntCustomerMeeting')->findAll()), | |||||
| 'customers' => Utils::clientMap($this->em, $this->em->getRepository(Customer::class)->findAll()), | |||||
| 'customerContacts' => Utils::clientMap($this->em, $this->em->getRepository(CustomerContact::class)->findAll()), | |||||
| 'customerMeetings' => Utils::clientMap($this->em, $this->em->getRepository(CustomerMeeting::class)->findAll()), | |||||
| ] | ] | ||||
| ); | ); | ||||
| } | } | ||||
| @@ -36,14 +40,13 @@ class CustomerViewController extends AbstractController | |||||
| public function getCustomerFull(Request $request) | public function getCustomerFull(Request $request) | ||||
| { | { | ||||
| $customerId = json_decode($request->request->get('customerId')); | $customerId = json_decode($request->request->get('customerId')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntCustomer $entCustomer */ | |||||
| $entCustomer = $em->getRepository('App:EntCustomer')->find($customerId); | |||||
| /** @var Customer $entCustomer */ | |||||
| $entCustomer = $this->em->getRepository(Customer::class)->find($customerId); | |||||
| if (is_null($entCustomer)) { | if (is_null($entCustomer)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| return Reply::getResponse($entCustomer->clientMapper($em, true)); | |||||
| return Reply::getResponse($entCustomer->clientMapper($this->em, true)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -7,8 +7,9 @@ | |||||
| */ | */ | ||||
| namespace App\Controller; | namespace App\Controller; | ||||
| use App\Entity\EntUser; | |||||
| use App\Entity\User; | |||||
| use App\Utils\Reply; | use App\Utils\Reply; | ||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Dompdf\Dompdf; | use Dompdf\Dompdf; | ||||
| use Dompdf\Options; | use Dompdf\Options; | ||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||||
| @@ -22,15 +23,16 @@ class ExportController extends AbstractController | |||||
| { | { | ||||
| const CONTACT_PDF_TYPE_CUSTOMER = 'customer'; | const CONTACT_PDF_TYPE_CUSTOMER = 'customer'; | ||||
| public function __construct(private EntityManagerInterface $em) {} | |||||
| #[Route('/get-customer-full', name: 'get_customer_full')] | #[Route('/get-customer-full', name: 'get_customer_full')] | ||||
| public function exportContacts(Request $request) | public function exportContacts(Request $request) | ||||
| { | { | ||||
| ini_set('max_execution_time', '300'); | ini_set('max_execution_time', '300'); | ||||
| ini_set('memory_limit','1024'); | ini_set('memory_limit','1024'); | ||||
| $type = $request->request->get('type'); | $type = $request->request->get('type'); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| $title = ""; | $title = ""; | ||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| @@ -43,7 +45,7 @@ class ExportController extends AbstractController | |||||
| FROM customer_contact cc, customer c | FROM customer_contact cc, customer c | ||||
| WHERE cc.customer_id = c.id | WHERE cc.customer_id = c.id | ||||
| ORDER BY company ASC, cc.lastname ASC"; | ORDER BY company ASC, cc.lastname ASC"; | ||||
| $statement = $em->getConnection()->prepare($sql); | |||||
| $statement = $this->em->getConnection()->prepare($sql); | |||||
| $statement->execute(); | $statement->execute(); | ||||
| $entries = $statement->fetchAll(); | $entries = $statement->fetchAll(); | ||||
| $title = "Kunden Kontakte"; | $title = "Kunden Kontakte"; | ||||
| @@ -7,13 +7,14 @@ | |||||
| */ | */ | ||||
| namespace App\Controller; | namespace App\Controller; | ||||
| use App\Entity\EntInternalMeeting; | |||||
| use App\Entity\EntInternalMeetingParticipant; | |||||
| use App\Entity\EntUser; | |||||
| use App\Entity\InternalMeeting; | |||||
| use App\Entity\InternalMeetingParticipant; | |||||
| use App\Entity\User; | |||||
| use App\EntityVirtual\ServiceData; | use App\EntityVirtual\ServiceData; | ||||
| use App\Utils\Message; | use App\Utils\Message; | ||||
| use App\Utils\Reply; | use App\Utils\Reply; | ||||
| use App\Utils\Utils; | use App\Utils\Utils; | ||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
| use Symfony\Component\Config\Definition\Exception\Exception; | use Symfony\Component\Config\Definition\Exception\Exception; | ||||
| @@ -23,16 +24,17 @@ use Symfony\Component\Routing\Annotation\Route; | |||||
| #[Security("is_granted('ROLE_USER')")] | #[Security("is_granted('ROLE_USER')")] | ||||
| class InternalMeetingEditController extends AbstractController | class InternalMeetingEditController extends AbstractController | ||||
| { | { | ||||
| public function __construct(private EntityManagerInterface $em) {} | |||||
| #[Route('/create-internal-meeting', name: 'create_internal_meeting')] | #[Route('/create-internal-meeting', name: 'create_internal_meeting')] | ||||
| public function createInternalMeeting(Request $request) | public function createInternalMeeting(Request $request) | ||||
| { | { | ||||
| $internalMeetingClient = json_decode($request->request->get('internalMeeting')); | $internalMeetingClient = json_decode($request->request->get('internalMeeting')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntUser $entOwnerUser */ | |||||
| $entOwnerUser = $em->getRepository('App:EntUser')->find($internalMeetingClient->owner_user_id); | |||||
| /** @var User $entOwnerUser */ | |||||
| $entOwnerUser = $this->em->getRepository(User::class)->find($internalMeetingClient->owner_user_id); | |||||
| if (is_null($entOwnerUser)) { | if (is_null($entOwnerUser)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| @@ -42,24 +44,24 @@ class InternalMeetingEditController extends AbstractController | |||||
| $dbCon->beginTransaction(); | $dbCon->beginTransaction(); | ||||
| try { | try { | ||||
| /** @var EntInternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = new EntInternalMeeting($em, $user, $entOwnerUser, $internalMeetingClient->title, $internalMeetingClient->start_date, $internalMeetingClient->end_date); | |||||
| $entInternalMeeting->setClientData($em, $internalMeetingClient); | |||||
| $em->persist($entInternalMeeting); | |||||
| $em->flush(); | |||||
| /** @var InternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = new InternalMeeting($this->em, $user, $entOwnerUser, $internalMeetingClient->title, $internalMeetingClient->start_date, $internalMeetingClient->end_date); | |||||
| $entInternalMeeting->setClientData($this->em, $internalMeetingClient); | |||||
| $this->em->persist($entInternalMeeting); | |||||
| $this->em->flush(); | |||||
| $cntParticipants = count($internalMeetingClient->v_participants); | $cntParticipants = count($internalMeetingClient->v_participants); | ||||
| for ($i = 0; $i < $cntParticipants; $i++) { | for ($i = 0; $i < $cntParticipants; $i++) { | ||||
| /** @var EntUser $participantUser */ | |||||
| $participantUser = $em->getRepository('App:EntUser')->find($internalMeetingClient->v_participants[$i]->participant_user_id); | |||||
| /** @var User $participantUser */ | |||||
| $participantUser = $this->em->getRepository(User::class)->find($internalMeetingClient->v_participants[$i]->participant_user_id); | |||||
| if (is_null($participantUser)) { | if (is_null($participantUser)) { | ||||
| throw new Exception('invalid participant user'); | throw new Exception('invalid participant user'); | ||||
| } | } | ||||
| /** @var EntInternalMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new EntInternalMeetingParticipant($em, $entInternalMeeting, $participantUser); | |||||
| $em->persist($entParticipant); | |||||
| /** @var InternalMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new InternalMeetingParticipant($this->em, $entInternalMeeting, $participantUser); | |||||
| $this->em->persist($entParticipant); | |||||
| } | } | ||||
| $em->flush(); | |||||
| $this->em->flush(); | |||||
| } catch (Exception $e) { | } catch (Exception $e) { | ||||
| return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | ||||
| @@ -67,7 +69,7 @@ class InternalMeetingEditController extends AbstractController | |||||
| // All data stored correctly | // All data stored correctly | ||||
| $dbCon->commit(); | $dbCon->commit(); | ||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($em, true); | |||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($this->em, true); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_ADD, $mappedInternalMeeting); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_ADD, $mappedInternalMeeting); | ||||
| return Reply::getResponse($mappedInternalMeeting, Message::SUCCESS_INTERNAL_MEETING_CREATE, 0, $serviceData); | return Reply::getResponse($mappedInternalMeeting, Message::SUCCESS_INTERNAL_MEETING_CREATE, 0, $serviceData); | ||||
| @@ -77,18 +79,17 @@ class InternalMeetingEditController extends AbstractController | |||||
| public function editInternalMeeting(Request $request) | public function editInternalMeeting(Request $request) | ||||
| { | { | ||||
| $internalMeetingClient = json_decode($request->request->get('internalMeeting')); | $internalMeetingClient = json_decode($request->request->get('internalMeeting')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntUser $entOwnerUser */ | |||||
| $entOwnerUser = $em->getRepository('App:EntUser')->find($internalMeetingClient->owner_user_id); | |||||
| /** @var User $entOwnerUser */ | |||||
| $entOwnerUser = $this->em->getRepository(User::class)->find($internalMeetingClient->owner_user_id); | |||||
| if (is_null($entOwnerUser)) { | if (is_null($entOwnerUser)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_DEFAULT); | return Reply::getErrorResponse(Message::ERROR_DEFAULT); | ||||
| } | } | ||||
| /** @var EntInternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $em->getRepository('App:EntInternalMeeting')->find($internalMeetingClient->id); | |||||
| /** @var InternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $this->em->getRepository(InternalMeeting::class)->find($internalMeetingClient->id); | |||||
| if (is_null($entInternalMeeting)) { | if (is_null($entInternalMeeting)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | ||||
| } | } | ||||
| @@ -110,37 +111,37 @@ class InternalMeetingEditController extends AbstractController | |||||
| $dbCon->beginTransaction(); | $dbCon->beginTransaction(); | ||||
| try { | try { | ||||
| $entInternalMeeting->setClientData($em, $internalMeetingClient); | |||||
| $em->persist($entInternalMeeting); | |||||
| $em->flush(); | |||||
| $entInternalMeeting->setClientData($this->em, $internalMeetingClient); | |||||
| $this->em->persist($entInternalMeeting); | |||||
| $this->em->flush(); | |||||
| $formerParticipantsByUserId = Utils::getSortedObjects('getParticipantUserId', | $formerParticipantsByUserId = Utils::getSortedObjects('getParticipantUserId', | ||||
| $em->getRepository('App:EntInternalMeetingParticipant')->findBy(['internal_meeting_id' => $entInternalMeeting->getId()])); | |||||
| $this->em->getRepository(InternalMeetingParticipant::class)->findBy(['internal_meeting_id' => $entInternalMeeting->getId()])); | |||||
| $pUserIdsToKeep = []; | $pUserIdsToKeep = []; | ||||
| $cntParticipants = count($internalMeetingClient->v_participants); | $cntParticipants = count($internalMeetingClient->v_participants); | ||||
| for ($i = 0; $i < $cntParticipants; $i++) { | for ($i = 0; $i < $cntParticipants; $i++) { | ||||
| if (!array_key_exists($internalMeetingClient->v_participants[$i]->participant_user_id, $formerParticipantsByUserId)) { | if (!array_key_exists($internalMeetingClient->v_participants[$i]->participant_user_id, $formerParticipantsByUserId)) { | ||||
| /** @var EntUser $participantUser */ | |||||
| $participantUser = $em->getRepository('App:EntUser')->find($internalMeetingClient->v_participants[$i]->participant_user_id); | |||||
| /** @var User $participantUser */ | |||||
| $participantUser = $this->em->getRepository(User::class)->find($internalMeetingClient->v_participants[$i]->participant_user_id); | |||||
| if (is_null($participantUser)) { | if (is_null($participantUser)) { | ||||
| throw new Exception('invalid participant user'); | throw new Exception('invalid participant user'); | ||||
| } | } | ||||
| /** @var EntInternalMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new EntInternalMeetingParticipant($em, $entInternalMeeting, $participantUser); | |||||
| $em->persist($entParticipant); | |||||
| /** @var InternalMeetingParticipant $entParticipant */ | |||||
| $entParticipant = new InternalMeetingParticipant($this->em, $entInternalMeeting, $participantUser); | |||||
| $this->em->persist($entParticipant); | |||||
| } else { | } else { | ||||
| $pUserIdsToKeep[$internalMeetingClient->v_participants[$i]->participant_user_id] = 1; | $pUserIdsToKeep[$internalMeetingClient->v_participants[$i]->participant_user_id] = 1; | ||||
| } | } | ||||
| } | } | ||||
| /** @var EntInternalMeetingParticipant $formerParticipant */ | |||||
| /** @var InternalMeetingParticipant $formerParticipant */ | |||||
| foreach ($formerParticipantsByUserId as $pUserId => $formerParticipant) { | foreach ($formerParticipantsByUserId as $pUserId => $formerParticipant) { | ||||
| if (!array_key_exists($pUserId, $pUserIdsToKeep)) { | if (!array_key_exists($pUserId, $pUserIdsToKeep)) { | ||||
| $em->remove($formerParticipant); | |||||
| $this->em->remove($formerParticipant); | |||||
| } | } | ||||
| } | } | ||||
| $em->flush(); | |||||
| $this->em->flush(); | |||||
| } catch (Exception $e) { | } catch (Exception $e) { | ||||
| return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | return Reply::getErrorResponse(Message::ERROR_INVALID_DATA); | ||||
| @@ -148,7 +149,7 @@ class InternalMeetingEditController extends AbstractController | |||||
| // All data stored correctly | // All data stored correctly | ||||
| $dbCon->commit(); | $dbCon->commit(); | ||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($em, true); | |||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($this->em, true); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_EDIT, $mappedInternalMeeting); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_EDIT, $mappedInternalMeeting); | ||||
| return Reply::getResponse($mappedInternalMeeting, Message::SUCCESS_INTERNAL_MEETING_EDIT, 0, $serviceData); | return Reply::getResponse($mappedInternalMeeting, Message::SUCCESS_INTERNAL_MEETING_EDIT, 0, $serviceData); | ||||
| @@ -158,12 +159,11 @@ class InternalMeetingEditController extends AbstractController | |||||
| public function deleteInternalMeeting(Request $request) | public function deleteInternalMeeting(Request $request) | ||||
| { | { | ||||
| $internalMeetingIdClient = json_decode($request->request->get('internalMeetingId')); | $internalMeetingIdClient = json_decode($request->request->get('internalMeetingId')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntInternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $em->getRepository('App:EntInternalMeeting')->find($internalMeetingIdClient); | |||||
| /** @var InternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $this->em->getRepository(InternalMeeting::class)->find($internalMeetingIdClient); | |||||
| if (is_null($entInternalMeeting)) { | if (is_null($entInternalMeeting)) { | ||||
| return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | return Reply::getErrorResponse(Message::ERROR_NON_EXISTING_DATA); | ||||
| } | } | ||||
| @@ -180,15 +180,15 @@ class InternalMeetingEditController extends AbstractController | |||||
| return Reply::getErrorResponse(Message::ERROR_MEETING_NOT_EDIT_DELETABLE); | return Reply::getErrorResponse(Message::ERROR_MEETING_NOT_EDIT_DELETABLE); | ||||
| } | } | ||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($em, true); | |||||
| $em->remove($entInternalMeeting); | |||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($this->em, true); | |||||
| $this->em->remove($entInternalMeeting); | |||||
| $participants = $em->getRepository('App:EntInternalMeetingParticipant')->findBy(['internal_meeting_id' => $entInternalMeeting->getId()]); | |||||
| /** @var EntInternalMeetingParticipant $participant */ | |||||
| $participants = $this->em->getRepository(InternalMeetingParticipant::class)->findBy(['internal_meeting_id' => $entInternalMeeting->getId()]); | |||||
| /** @var InternalMeetingParticipant $participant */ | |||||
| foreach ($participants as $participant) { | foreach ($participants as $participant) { | ||||
| $em->remove($participant); | |||||
| $this->em->remove($participant); | |||||
| } | } | ||||
| $em->flush(); | |||||
| $this->em->flush(); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_DELETE, $mappedInternalMeeting); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_DELETE, $mappedInternalMeeting); | ||||
| @@ -199,12 +199,11 @@ class InternalMeetingEditController extends AbstractController | |||||
| public function checkInternalMeetingReport(Request $request) | public function checkInternalMeetingReport(Request $request) | ||||
| { | { | ||||
| $internalMeetingIdClient = json_decode($request->request->get('internalMeetingId')); | $internalMeetingIdClient = json_decode($request->request->get('internalMeetingId')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntInternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $em->getRepository('App:EntInternalMeeting')->find($internalMeetingIdClient); | |||||
| /** @var InternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $this->em->getRepository(InternalMeeting::class)->find($internalMeetingIdClient); | |||||
| $bHasRightsToMakeReport = | $bHasRightsToMakeReport = | ||||
| $entInternalMeeting->getOwnerUserId() == $user->getId() || | $entInternalMeeting->getOwnerUserId() == $user->getId() || | ||||
| $user->isAdmin(); | $user->isAdmin(); | ||||
| @@ -221,13 +220,12 @@ class InternalMeetingEditController extends AbstractController | |||||
| { | { | ||||
| $internalMeetingIdClient = json_decode($request->request->get('internalMeetingId')); | $internalMeetingIdClient = json_decode($request->request->get('internalMeetingId')); | ||||
| $internalMeetingReportClient = json_decode($request->request->get('internalMeetingReport')); | $internalMeetingReportClient = json_decode($request->request->get('internalMeetingReport')); | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| /** @var EntUser $user */ | |||||
| /** @var User $user */ | |||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| /** @var EntInternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $em->getRepository('App:EntInternalMeeting')->find($internalMeetingIdClient); | |||||
| /** @var InternalMeeting $entInternalMeeting */ | |||||
| $entInternalMeeting = $this->em->getRepository(InternalMeeting::class)->find($internalMeetingIdClient); | |||||
| $bHasRightsToMakeReport = | $bHasRightsToMakeReport = | ||||
| $entInternalMeeting->getOwnerUserId() == $user->getId() || | $entInternalMeeting->getOwnerUserId() == $user->getId() || | ||||
| $user->isAdmin(); | $user->isAdmin(); | ||||
| @@ -236,10 +234,10 @@ class InternalMeetingEditController extends AbstractController | |||||
| } | } | ||||
| $entInternalMeeting->setReport($internalMeetingReportClient); | $entInternalMeeting->setReport($internalMeetingReportClient); | ||||
| $em->persist($entInternalMeeting); | |||||
| $em->flush(); | |||||
| $this->em->persist($entInternalMeeting); | |||||
| $this->em->flush(); | |||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($em, true); | |||||
| $mappedInternalMeeting = $entInternalMeeting->clientMapper($this->em, true); | |||||
| $serviceData = new ServiceData(); | $serviceData = new ServiceData(); | ||||
| $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_EDIT, $mappedInternalMeeting); | $serviceData->addServiceData(ServiceData::SERVICE_DATA_TYPE_INTERNAL_MEETINGS, ServiceData::ACTION_EDIT, $mappedInternalMeeting); | ||||
| return Reply::getResponse($mappedInternalMeeting, Message::SUCCESS_INTERNAL_MEETING_REPORT_SET, 0, $serviceData); | return Reply::getResponse($mappedInternalMeeting, Message::SUCCESS_INTERNAL_MEETING_REPORT_SET, 0, $serviceData); | ||||
| @@ -7,12 +7,13 @@ | |||||
| */ | */ | ||||
| namespace App\Controller; | namespace App\Controller; | ||||
| use App\Entity\EntCustomerMeeting; | |||||
| use App\Entity\EntInternalMeeting; | |||||
| use App\Entity\CustomerMeeting; | |||||
| use App\Entity\InternalMeeting; | |||||
| use App\Utils\Excel; | use App\Utils\Excel; | ||||
| use App\Utils\ExcelStyle; | use App\Utils\ExcelStyle; | ||||
| use App\Utils\Reply; | use App\Utils\Reply; | ||||
| use App\Utils\Utils; | use App\Utils\Utils; | ||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use PhpOffice\PhpSpreadsheet\Spreadsheet; | use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||||
| use PhpOffice\PhpSpreadsheet\Style\Alignment; | use PhpOffice\PhpSpreadsheet\Style\Alignment; | ||||
| use PhpOffice\PhpSpreadsheet\Writer\Xlsx; | use PhpOffice\PhpSpreadsheet\Writer\Xlsx; | ||||
| @@ -24,14 +25,15 @@ use Symfony\Component\Routing\Annotation\Route; | |||||
| #[Security("is_granted('ROLE_USER')")] | #[Security("is_granted('ROLE_USER')")] | ||||
| class MeetingViewController extends AbstractController | class MeetingViewController extends AbstractController | ||||
| { | { | ||||
| public function __construct(private EntityManagerInterface $em) {} | |||||
| #[Route('/get-meeting-data', name: 'get_meeting_data')] | #[Route('/get-meeting-data', name: 'get_meeting_data')] | ||||
| public function getMeetingData() | public function getMeetingData() | ||||
| { | { | ||||
| $em = $this->getDoctrine()->getManager(); | |||||
| return Reply::getResponse( | return Reply::getResponse( | ||||
| [ | [ | ||||
| 'customerMeetings' => Utils::clientMap($em, $em->getRepository(EntCustomerMeeting::class)->findAll()), | |||||
| 'internalMeetings' => Utils::clientMap($em, $em->getRepository(EntInternalMeeting::class)->findAll()), | |||||
| 'customerMeetings' => Utils::clientMap($this->em, $this->em->getRepository(CustomerMeeting::class)->findAll()), | |||||
| 'internalMeetings' => Utils::clientMap($this->em, $this->em->getRepository(InternalMeeting::class)->findAll()), | |||||
| ] | ] | ||||
| ); | ); | ||||
| } | } | ||||
| @@ -51,7 +51,7 @@ class PublicController extends AbstractController | |||||
| } | } | ||||
| #[Route('/logout', name: 'security_logout')] | #[Route('/logout', name: 'security_logout')] | ||||
| public function logoutAction() | |||||
| public function logoutAction(): never | |||||
| { | { | ||||
| throw new Exception('this should not be reached'); | throw new Exception('this should not be reached'); | ||||
| } | } | ||||
| @@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM; | |||||
| #[ORM\Table(name: 'country')] | #[ORM\Table(name: 'country')] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntCountry implements IEntity | |||||
| class Country implements IEntity | |||||
| { | { | ||||
| const COUNTRY_GERMANY_ID = 1; | const COUNTRY_GERMANY_ID = 1; | ||||
| const COUNTRY_AUSTRIA_ID = 2; | const COUNTRY_AUSTRIA_ID = 2; | ||||
| @@ -47,7 +47,7 @@ class EntCountry implements IEntity | |||||
| public static function getCountriesById(EntityManagerInterface $em) | public static function getCountriesById(EntityManagerInterface $em) | ||||
| { | { | ||||
| if (is_null(self::$cacheCountriesById)) { | if (is_null(self::$cacheCountriesById)) { | ||||
| self::$cacheCountriesById = Utils::getSortedObjectsById($em->getRepository('App:EntCountry')->findAll()); | |||||
| self::$cacheCountriesById = Utils::getSortedObjectsById($em->getRepository(self::class)->findAll()); | |||||
| } | } | ||||
| return self::$cacheCountriesById; | return self::$cacheCountriesById; | ||||
| } | } | ||||
| @@ -80,7 +80,7 @@ class EntCountry implements IEntity | |||||
| } | } | ||||
| /** | /** | ||||
| * EntCountry constructor. | |||||
| * Country constructor. | |||||
| * @param $countryName | * @param $countryName | ||||
| * @param $isoCode | * @param $isoCode | ||||
| */ | */ | ||||
| @@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM; | |||||
| #[ORM\Table(name: 'customer')] | #[ORM\Table(name: 'customer')] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntCustomer implements IEntity | |||||
| class Customer implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -69,7 +69,7 @@ class EntCustomer implements IEntity | |||||
| protected $creation_date; | protected $creation_date; | ||||
| /** | /** | ||||
| * EntCustomer constructor. | |||||
| * Customer constructor. | |||||
| * @param ObjectManager $em | * @param ObjectManager $em | ||||
| * @param $name | * @param $name | ||||
| * @throws \Exception | * @throws \Exception | ||||
| @@ -409,9 +409,9 @@ class EntCustomer implements IEntity | |||||
| ]; | ]; | ||||
| if ($fullMapping) { | if ($fullMapping) { | ||||
| $res['v_customer_contacts'] = Utils::clientMap($em, $em->getRepository('App:EntCustomerContact')->findBy(['customer_id' => $this->getId()])); | |||||
| $res['v_customer_notes'] = Utils::clientMap($em, $em->getRepository('App:EntCustomerNote')->findBy(['customer_id' => $this->getId()])); | |||||
| $res['v_customer_meetings'] = Utils::clientMap($em, $em->getRepository('App:EntCustomerMeeting')->findBy(['customer_id' => $this->getId()])); | |||||
| $res['v_customer_contacts'] = Utils::clientMap($em, $em->getRepository(CustomerContact::class)->findBy(['customer_id' => $this->getId()])); | |||||
| $res['v_customer_notes'] = Utils::clientMap($em, $em->getRepository(CustomerNote::class)->findBy(['customer_id' => $this->getId()])); | |||||
| $res['v_customer_meetings'] = Utils::clientMap($em, $em->getRepository(CustomerMeeting::class)->findBy(['customer_id' => $this->getId()])); | |||||
| } | } | ||||
| return $res; | return $res; | ||||
| @@ -12,7 +12,7 @@ use Symfony\Component\Config\Definition\Exception\Exception; | |||||
| #[ORM\Table(name: 'customer_contact')] | #[ORM\Table(name: 'customer_contact')] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntCustomerContact implements IEntity | |||||
| class CustomerContact implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -74,13 +74,13 @@ class EntCustomerContact implements IEntity | |||||
| protected $is_xmas_mail_recipient = false; | protected $is_xmas_mail_recipient = false; | ||||
| /** | /** | ||||
| * EntCustomerContact constructor. | |||||
| * CustomerContact constructor. | |||||
| * @param EntityManagerInterface $em | * @param EntityManagerInterface $em | ||||
| * @param EntCustomer $entCustomer | |||||
| * @param Customer $entCustomer | |||||
| * @param $lastName | * @param $lastName | ||||
| * @throws \Exception | * @throws \Exception | ||||
| */ | */ | ||||
| public function __construct(EntityManagerInterface $em, EntCustomer $entCustomer, $lastName) | |||||
| public function __construct(EntityManagerInterface $em, Customer $entCustomer, $lastName) | |||||
| { | { | ||||
| if (is_null($entCustomer->getId())) { | if (is_null($entCustomer->getId())) { | ||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| @@ -12,7 +12,7 @@ use Symfony\Component\Config\Definition\Exception\Exception; | |||||
| #[ORM\Table(name: 'customer_meeting')] | #[ORM\Table(name: 'customer_meeting')] | ||||
| #[ORM\Index(name: 'search_customer_idx', columns: ['customer_id', 'owner_user_id', 'customer_contact_id'])] | #[ORM\Index(name: 'search_customer_idx', columns: ['customer_id', 'owner_user_id', 'customer_contact_id'])] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntCustomerMeeting implements IEntity | |||||
| class CustomerMeeting implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -105,20 +105,20 @@ class EntCustomerMeeting implements IEntity | |||||
| /** | /** | ||||
| * EntCustomerMeeting constructor. | |||||
| * CustomerMeeting constructor. | |||||
| * @param ObjectManager $em | * @param ObjectManager $em | ||||
| * @param EntCustomer $entCustomer | |||||
| * @param EntUser $entCreationUser | |||||
| * @param EntUser $entOwnerUser | |||||
| * @param EntMeetingType $entMeetingType | |||||
| * @param Customer $entCustomer | |||||
| * @param User $entCreationUser | |||||
| * @param User $entOwnerUser | |||||
| * @param MeetingType $entMeetingType | |||||
| * @param $isOptionMeeting | * @param $isOptionMeeting | ||||
| * @param $title | * @param $title | ||||
| * @param $startDate | * @param $startDate | ||||
| * @param $endDate | * @param $endDate | ||||
| * @throws \Exception | * @throws \Exception | ||||
| */ | */ | ||||
| public function __construct(ObjectManager $em, EntCustomer $entCustomer, EntUser $entCreationUser, EntUser $entOwnerUser, | |||||
| EntMeetingType $entMeetingType, $isOptionMeeting, $title, $startDate, $endDate) | |||||
| public function __construct(ObjectManager $em, Customer $entCustomer, User $entCreationUser, User $entOwnerUser, | |||||
| MeetingType $entMeetingType, $isOptionMeeting, $title, $startDate, $endDate) | |||||
| { | { | ||||
| if (is_null($entCustomer->getId())) { | if (is_null($entCustomer->getId())) { | ||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| @@ -132,7 +132,7 @@ class EntCustomerMeeting implements IEntity | |||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| } | } | ||||
| $meetingTypesById = EntMeetingType::getMeetingTypesById($em); | |||||
| $meetingTypesById = MeetingType::getMeetingTypesById($em); | |||||
| if (is_null($entMeetingType->getId()) || !array_key_exists($entMeetingType->getId(), $meetingTypesById)) { | if (is_null($entMeetingType->getId()) || !array_key_exists($entMeetingType->getId(), $meetingTypesById)) { | ||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| } | } | ||||
| @@ -460,8 +460,8 @@ class EntCustomerMeeting implements IEntity | |||||
| if ($customer_contact_id == 0) { | if ($customer_contact_id == 0) { | ||||
| $this->customer_contact_id = $customer_contact_id; | $this->customer_contact_id = $customer_contact_id; | ||||
| } else { | } else { | ||||
| /** @var EntCustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $em->getRepository('App:EntCustomerContact')->find($customer_contact_id); | |||||
| /** @var CustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $em->getRepository(CustomerContact::class)->find($customer_contact_id); | |||||
| // NOTE: Check if contact still exists | // NOTE: Check if contact still exists | ||||
| $this->customer_contact_id = !is_null($entCustomerContact) ? $customer_contact_id : null; | $this->customer_contact_id = !is_null($entCustomerContact) ? $customer_contact_id : null; | ||||
| } | } | ||||
| @@ -691,7 +691,7 @@ class EntCustomerMeeting implements IEntity | |||||
| 'report_done' => $this->report_done, | 'report_done' => $this->report_done, | ||||
| 'report_reminder_sent' => $this->report_reminder_sent, | 'report_reminder_sent' => $this->report_reminder_sent, | ||||
| 'creation_date' => !is_null($this->creation_date) ? $this->creation_date->format('Y-m-d H:i:s'): null, | 'creation_date' => !is_null($this->creation_date) ? $this->creation_date->format('Y-m-d H:i:s'): null, | ||||
| 'v_participants' => Utils::clientMap($em, $em->getRepository('App:EntCustomerMeetingParticipant')->findBy(['customer_meeting_id' => $this->id])), | |||||
| 'v_participants' => Utils::clientMap($em, $em->getRepository(CustomerMeetingParticipant::class)->findBy(['customer_meeting_id' => $this->id])), | |||||
| 'v_is_editable' => $now < $this->start_date, | 'v_is_editable' => $now < $this->start_date, | ||||
| ]; | ]; | ||||
| } | } | ||||
| @@ -13,7 +13,7 @@ use Symfony\Component\Config\Definition\Exception\Exception; | |||||
| #[ORM\Index(name: 'search_participant_idx', columns: ['customer_meeting_id', 'participant_user_id'])] | #[ORM\Index(name: 'search_participant_idx', columns: ['customer_meeting_id', 'participant_user_id'])] | ||||
| #[UniqueConstraint(name: 'unique_participant', columns: ['customer_meeting_id', 'participant_user_id'])] | #[UniqueConstraint(name: 'unique_participant', columns: ['customer_meeting_id', 'participant_user_id'])] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntCustomerMeetingParticipant implements IEntity | |||||
| class CustomerMeetingParticipant implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -28,12 +28,12 @@ class EntCustomerMeetingParticipant implements IEntity | |||||
| /** | /** | ||||
| * EntCustomerMeetingParticipant constructor. | |||||
| * CustomerMeetingParticipant constructor. | |||||
| * @param EntityManagerInterface $em | * @param EntityManagerInterface $em | ||||
| * @param EntCustomerMeeting $entCustomerMeeting | |||||
| * @param EntUser $entParticipantUser | |||||
| * @param CustomerMeeting $entCustomerMeeting | |||||
| * @param User $entParticipantUser | |||||
| */ | */ | ||||
| public function __construct(EntityManagerInterface $em, EntCustomerMeeting $entCustomerMeeting, EntUser $entParticipantUser) | |||||
| public function __construct(EntityManagerInterface $em, CustomerMeeting $entCustomerMeeting, User $entParticipantUser) | |||||
| { | { | ||||
| if (is_null($entCustomerMeeting->getId())) { | if (is_null($entCustomerMeeting->getId())) { | ||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| @@ -11,7 +11,7 @@ use Symfony\Component\Config\Definition\Exception\Exception; | |||||
| #[ORM\Table(name: 'customer_note')] | #[ORM\Table(name: 'customer_note')] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntCustomerNote implements IEntity | |||||
| class CustomerNote implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -71,14 +71,14 @@ class EntCustomerNote implements IEntity | |||||
| /** | /** | ||||
| * EntCustomerNote constructor. | |||||
| * CustomerNote constructor. | |||||
| * @param ObjectManager $em | * @param ObjectManager $em | ||||
| * @param EntCustomer $entCustomer | |||||
| * @param EntUser $entUser | |||||
| * @param Customer $entCustomer | |||||
| * @param User $entUser | |||||
| * @param $title | * @param $title | ||||
| * @throws \Exception | * @throws \Exception | ||||
| */ | */ | ||||
| public function __construct(ObjectManager $em, EntCustomer $entCustomer, EntUser $entUser, $title) | |||||
| public function __construct(ObjectManager $em, Customer $entCustomer, User $entUser, $title) | |||||
| { | { | ||||
| if (is_null($entCustomer->getId())) { | if (is_null($entCustomer->getId())) { | ||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| @@ -250,8 +250,8 @@ class EntCustomerNote implements IEntity | |||||
| if ($customer_contact_id == 0) { | if ($customer_contact_id == 0) { | ||||
| $this->customer_contact_id = $customer_contact_id; | $this->customer_contact_id = $customer_contact_id; | ||||
| } else { | } else { | ||||
| /** @var EntCustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $em->getRepository('App:EntCustomerContact')->find($customer_contact_id); | |||||
| /** @var CustomerContact $entCustomerContact */ | |||||
| $entCustomerContact = $em->getRepository(CustomerContact::class)->find($customer_contact_id); | |||||
| // NOTE: Check if contact still exists | // NOTE: Check if contact still exists | ||||
| $this->customer_contact_id = !is_null($entCustomerContact) ? $customer_contact_id : null; | $this->customer_contact_id = !is_null($entCustomerContact) ? $customer_contact_id : null; | ||||
| } | } | ||||
| @@ -1,155 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Entity; | |||||
| use App\Entity\IFace\IEntity; | |||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Symfony\Component\Config\Definition\Exception\Exception; | |||||
| use Doctrine\ORM\Mapping as ORM; | |||||
| #[ORM\Table(name: 'user_type')] | |||||
| #[ORM\Entity] | |||||
| class EntUserType implements IEntity | |||||
| { | |||||
| // User type for system | |||||
| const USER_TYPE_ID_SYSTEM = 0; | |||||
| // User types for real users | |||||
| const USER_TYPE_ID_ADMIN = 1; | |||||
| const USER_TYPE_ID_SALES = 2; | |||||
| const USER_TYPE_ID_TECHNIQUE = 3; | |||||
| const USER_TYPE_ID_PRODUCTION = 4; | |||||
| const USER_TYPE_ID_ACCOUNTING = 5; | |||||
| const USER_TYPE_ID_SERVICE = 6; | |||||
| const USER_ROLE_ADMIN = 'ROLE_ADMIN'; | |||||
| const USER_ROLE_USER = 'ROLE_USER'; | |||||
| const USER_ROLE_SALES = 'ROLE_SALES'; | |||||
| const USER_ROLE_TECHNIQUE = 'ROLE_TECHNIQUE'; | |||||
| const USER_ROLE_PRODUCTION = 'ROLE_PRODUCTION'; | |||||
| const USER_ROLE_ACCOUNTING = 'ROLE_ACCOUNTING'; | |||||
| const USER_ROLE_SERVICE = 'ROLE_SERVICE'; | |||||
| // Maps user type to set of roles | |||||
| private static $userRoles = array( | |||||
| self::USER_TYPE_ID_ADMIN => array(self::USER_ROLE_ADMIN, self::USER_ROLE_USER, self::USER_ROLE_SALES, self::USER_ROLE_TECHNIQUE, | |||||
| self::USER_ROLE_PRODUCTION, self::USER_ROLE_ACCOUNTING, self::USER_ROLE_SERVICE), | |||||
| self::USER_TYPE_ID_SALES => array(self::USER_ROLE_USER, self::USER_ROLE_SALES), | |||||
| self::USER_TYPE_ID_TECHNIQUE => array(self::USER_ROLE_USER, self::USER_ROLE_TECHNIQUE, self::USER_ROLE_PRODUCTION, self::USER_ROLE_SERVICE), | |||||
| self::USER_TYPE_ID_PRODUCTION => array(self::USER_ROLE_USER, self::USER_ROLE_PRODUCTION, self::USER_ROLE_SERVICE), | |||||
| self::USER_TYPE_ID_ACCOUNTING => array(self::USER_ROLE_USER, self::USER_ROLE_ACCOUNTING), | |||||
| self::USER_TYPE_ID_SERVICE => array(self::USER_ROLE_USER, self::USER_ROLE_SERVICE, self::USER_ROLE_PRODUCTION), | |||||
| ); | |||||
| // Role translations for client | |||||
| private static $translatedRoles = array( | |||||
| self::USER_TYPE_ID_ADMIN => 'Admin', | |||||
| self::USER_TYPE_ID_SALES => 'Vertrieb', | |||||
| self::USER_TYPE_ID_TECHNIQUE => 'Technik', | |||||
| self::USER_TYPE_ID_PRODUCTION => 'Produktion', | |||||
| self::USER_TYPE_ID_ACCOUNTING => 'Buchhaltung', | |||||
| self::USER_TYPE_ID_SERVICE => 'Service' | |||||
| ); | |||||
| #[ORM\Id] | |||||
| #[ORM\GeneratedValue] | |||||
| #[ORM\Column(type: 'integer')] | |||||
| protected $id; | |||||
| #[ORM\Column(name: 'type', type: 'string', nullable: false, unique: true)] | |||||
| protected $type; | |||||
| public function __construct($type) | |||||
| { | |||||
| $this->type = $type; | |||||
| } | |||||
| /** | |||||
| * @return mixed | |||||
| */ | |||||
| public function getId() | |||||
| { | |||||
| return $this->id; | |||||
| } | |||||
| /** | |||||
| * @return mixed | |||||
| */ | |||||
| public function getType() | |||||
| { | |||||
| return $this->type; | |||||
| } | |||||
| /** | |||||
| * Returns all available user roles | |||||
| * @return array | |||||
| */ | |||||
| public static function getAllUserRoles() | |||||
| { | |||||
| return self::$userRoles; | |||||
| } | |||||
| /** | |||||
| * Returns user roles | |||||
| * @param $userTypeId | |||||
| * @return string[] | |||||
| */ | |||||
| public static function getUserRoles($userTypeId) | |||||
| { | |||||
| if (!array_key_exists($userTypeId, self::$userRoles)) { | |||||
| throw new Exception("unknown user type"); | |||||
| } | |||||
| return self::$userRoles[$userTypeId]; | |||||
| } | |||||
| public static function getTranslatedRole($userTypeId) | |||||
| { | |||||
| if (!array_key_exists($userTypeId, self::$translatedRoles)) { | |||||
| throw new Exception('invalid user type id given'); | |||||
| } | |||||
| return self::$translatedRoles[$userTypeId]; | |||||
| } | |||||
| /** | |||||
| * Returns role config | |||||
| * @return array | |||||
| */ | |||||
| public static function getRolesConfig() | |||||
| { | |||||
| $rolesConfig = array(); | |||||
| foreach (self::$userRoles as $userTypeId => $ur) { | |||||
| $rolesConfig[] = array( | |||||
| 'user_type_id' => $userTypeId, | |||||
| 'roles' => $ur, | |||||
| 'translation' => self::$translatedRoles[$userTypeId] | |||||
| ); | |||||
| } | |||||
| return $rolesConfig; | |||||
| } | |||||
| public static function isValidUserTypeId($userTypeId) | |||||
| { | |||||
| return array_key_exists($userTypeId, self::$userRoles); | |||||
| } | |||||
| /** | |||||
| * Check if a given user type is higher than given compare id | |||||
| * @param $higherUserTypeId | |||||
| * @return bool | |||||
| */ | |||||
| public static function isHigherUserType($higherUserTypeId, $lowerUserTypeId) | |||||
| { | |||||
| return $higherUserTypeId < $lowerUserTypeId; | |||||
| } | |||||
| public function clientMapper(EntityManagerInterface $em, $fullMapping = false) { | |||||
| return [ | |||||
| 'user_type_id' => $this->getId(), | |||||
| 'type' => $this->type, | |||||
| 'v_roles' => self::getUserRoles($this->getId()) | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -12,7 +12,7 @@ use Symfony\Component\Config\Definition\Exception\Exception; | |||||
| #[ORM\Table(name: 'internal_meeting')] | #[ORM\Table(name: 'internal_meeting')] | ||||
| #[ORM\Index(name: 'search_owner_idx', columns: ['owner_user_id'])] | #[ORM\Index(name: 'search_owner_idx', columns: ['owner_user_id'])] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntInternalMeeting implements IEntity | |||||
| class InternalMeeting implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -54,16 +54,16 @@ class EntInternalMeeting implements IEntity | |||||
| /** | /** | ||||
| * EntInternalMeeting constructor. | |||||
| * InternalMeeting constructor. | |||||
| * @param ObjectManager $em | * @param ObjectManager $em | ||||
| * @param EntUser $entCreationUser | |||||
| * @param EntUser $entOwnerUser | |||||
| * @param User $entCreationUser | |||||
| * @param User $entOwnerUser | |||||
| * @param $title | * @param $title | ||||
| * @param $startDate | * @param $startDate | ||||
| * @param $endDate | * @param $endDate | ||||
| * @throws \Exception | * @throws \Exception | ||||
| */ | */ | ||||
| public function __construct(ObjectManager $em, EntUser $entCreationUser, EntUser $entOwnerUser, $title, $startDate, $endDate) | |||||
| public function __construct(ObjectManager $em, User $entCreationUser, User $entOwnerUser, $title, $startDate, $endDate) | |||||
| { | { | ||||
| if (is_null($entCreationUser->getId())) { | if (is_null($entCreationUser->getId())) { | ||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| @@ -305,7 +305,7 @@ class EntInternalMeeting implements IEntity | |||||
| 'second_reminder_sent' => $this->second_reminder_sent, | 'second_reminder_sent' => $this->second_reminder_sent, | ||||
| 'report_reminder_sent' => $this->report_reminder_sent, | 'report_reminder_sent' => $this->report_reminder_sent, | ||||
| 'creation_date' => !is_null($this->creation_date) ? $this->creation_date->format('Y-m-d H:i:s'): null, | 'creation_date' => !is_null($this->creation_date) ? $this->creation_date->format('Y-m-d H:i:s'): null, | ||||
| 'v_participants' => Utils::clientMap($em, $em->getRepository('App:EntInternalMeetingParticipant')->findBy(['internal_meeting_id' => $this->id])), | |||||
| 'v_participants' => Utils::clientMap($em, $em->getRepository(InternalMeetingParticipant::class)->findBy(['internal_meeting_id' => $this->id])), | |||||
| 'v_is_editable' => $now < $this->start_date, | 'v_is_editable' => $now < $this->start_date, | ||||
| ]; | ]; | ||||
| } | } | ||||
| @@ -13,7 +13,7 @@ use Symfony\Component\Config\Definition\Exception\Exception; | |||||
| #[ORM\Index(name: 'search_participant_idx', columns: ['internal_meeting_id', 'participant_user_id'])] | #[ORM\Index(name: 'search_participant_idx', columns: ['internal_meeting_id', 'participant_user_id'])] | ||||
| #[UniqueConstraint(name: 'unique_participant', columns: ['internal_meeting_id', 'participant_user_id'])] | #[UniqueConstraint(name: 'unique_participant', columns: ['internal_meeting_id', 'participant_user_id'])] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntInternalMeetingParticipant implements IEntity | |||||
| class InternalMeetingParticipant implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -28,12 +28,12 @@ class EntInternalMeetingParticipant implements IEntity | |||||
| /** | /** | ||||
| * EntInternalMeetingParticipant constructor. | |||||
| * InternalMeetingParticipant constructor. | |||||
| * @param EntityManagerInterface $em | * @param EntityManagerInterface $em | ||||
| * @param EntInternalMeeting $entInternalMeeting | |||||
| * @param EntUser $entParticipantUser | |||||
| * @param InternalMeeting $entInternalMeeting | |||||
| * @param User $entParticipantUser | |||||
| */ | */ | ||||
| public function __construct(EntityManagerInterface $em, EntInternalMeeting $entInternalMeeting, EntUser $entParticipantUser) | |||||
| public function __construct(EntityManagerInterface $em, InternalMeeting $entInternalMeeting, User $entParticipantUser) | |||||
| { | { | ||||
| if (is_null($entInternalMeeting->getId())) { | if (is_null($entInternalMeeting->getId())) { | ||||
| throw new Exception('no id found'); | throw new Exception('no id found'); | ||||
| @@ -9,7 +9,7 @@ use Doctrine\ORM\Mapping as ORM; | |||||
| #[ORM\Table(name: 'meeting_type')] | #[ORM\Table(name: 'meeting_type')] | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| class EntMeetingType implements IEntity | |||||
| class MeetingType implements IEntity | |||||
| { | { | ||||
| #[ORM\Id] | #[ORM\Id] | ||||
| #[ORM\GeneratedValue] | #[ORM\GeneratedValue] | ||||
| @@ -32,7 +32,7 @@ class EntMeetingType implements IEntity | |||||
| public static function getMeetingTypesById(EntityManagerInterface $em) | public static function getMeetingTypesById(EntityManagerInterface $em) | ||||
| { | { | ||||
| if (is_null(self::$cacheMeetingTypesById)) { | if (is_null(self::$cacheMeetingTypesById)) { | ||||
| self::$cacheMeetingTypesById = Utils::getSortedObjectsById($em->getRepository('App:EntMeetingType')->findAll()); | |||||
| self::$cacheMeetingTypesById = Utils::getSortedObjectsById($em->getRepository(self::class)->findAll()); | |||||
| } | } | ||||
| return self::$cacheMeetingTypesById; | return self::$cacheMeetingTypesById; | ||||
| } | } | ||||
| @@ -8,14 +8,19 @@ use App\Utils\Utils; | |||||
| use Doctrine\DBAL\Types\Types; | use Doctrine\DBAL\Types\Types; | ||||
| use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
| use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
| use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; | |||||
| use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface; | |||||
| use Symfony\Component\Config\Definition\Exception\Exception; | use Symfony\Component\Config\Definition\Exception\Exception; | ||||
| use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; | use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; | ||||
| use Symfony\Component\Security\Core\User\UserInterface; | use Symfony\Component\Security\Core\User\UserInterface; | ||||
| #[ORM\Entity] | #[ORM\Entity] | ||||
| #[ORM\Table(name: "user")] | #[ORM\Table(name: "user")] | ||||
| class EntUser implements IEntity, UserInterface, PasswordAuthenticatedUserInterface | |||||
| class User implements IEntity, UserInterface, PasswordAuthenticatedUserInterface//, UserLoaderInterface | |||||
| { | { | ||||
| const USER_ROLE_ADMIN = "ROLE_ADMIN"; | |||||
| const USER_ROLE_USER = "ROLE_USER"; | |||||
| // Costs of password encryption | // Costs of password encryption | ||||
| const CRYPT_COST = 12; | const CRYPT_COST = 12; | ||||
| @@ -48,18 +53,7 @@ class EntUser implements IEntity, UserInterface, PasswordAuthenticatedUserInterf | |||||
| #[ORM\Column(type: 'datetime', nullable: false)] | #[ORM\Column(type: 'datetime', nullable: false)] | ||||
| protected $creation_date; | protected $creation_date; | ||||
| /** | |||||
| * EntUser constructor. | |||||
| * @param EntityManagerInterface $em | |||||
| * @param $email | |||||
| * @param $firstName | |||||
| * @param $lastName | |||||
| * @param $password | |||||
| * @param $userTypeIdCreatingUser | |||||
| * @param EntUser|null $editingUser | |||||
| * @throws \Exception | |||||
| */ | |||||
| public function __construct(EntityManagerInterface $em, $email, $firstName, $lastName, $password, $userTypeIdCreatingUser, EntUser $editingUser = null) | |||||
| public function __construct(EntityManagerInterface $em, $email, $firstName, $lastName, $password, $userTypeIdCreatingUser, User $editingUser = null) | |||||
| { | { | ||||
| // Check email | // Check email | ||||
| if (!Utils::validateEmail($em, $email)) { | if (!Utils::validateEmail($em, $email)) { | ||||
| @@ -154,6 +148,11 @@ class EntUser implements IEntity, UserInterface, PasswordAuthenticatedUserInterf | |||||
| return $this->email; | return $this->email; | ||||
| } | } | ||||
| // public function loadUserByIdentifier(string $identifier): ?UserInterface | |||||
| // { | |||||
| // // TODO: Implement loadUserByIdentifier() method. | |||||
| // } | |||||
| public function getRoles(): array | public function getRoles(): array | ||||
| { | { | ||||
| $roles = $this->roles; | $roles = $this->roles; | ||||
| @@ -170,42 +169,30 @@ class EntUser implements IEntity, UserInterface, PasswordAuthenticatedUserInterf | |||||
| return $this; | return $this; | ||||
| } | } | ||||
| /** | |||||
| * Returns if user has admin rights | |||||
| * @return bool | |||||
| */ | |||||
| public function isAdmin() | public function isAdmin() | ||||
| { | { | ||||
| return in_array(EntUserType::USER_ROLE_ADMIN, $this->getRoles()); | |||||
| return in_array(self::USER_ROLE_ADMIN, $this->getRoles(), true); | |||||
| } | } | ||||
| /** | |||||
| * Erases credentials as part of UserInterface needed in Symfony | |||||
| */ | |||||
| public function eraseCredentials() {} | public function eraseCredentials() {} | ||||
| /** | |||||
| * Checks password as part of UserInterface needed in Symfony | |||||
| * @param $password | |||||
| * @return bool | |||||
| */ | |||||
| public function checkPassword($password) | public function checkPassword($password) | ||||
| { | { | ||||
| return $this->active && password_verify($password, $this->password); | return $this->active && password_verify($password, $this->password); | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns salt as part of UserInterface needed in Symfony | |||||
| * @return null|string|void | |||||
| * Returning a salt is only needed if you are not using a modern | |||||
| * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml. | |||||
| * | |||||
| * @see UserInterface | |||||
| */ | */ | ||||
| public function getSalt() {} | |||||
| public function getSalt(): ?string | |||||
| { | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * Sets email with check on validity and existence | |||||
| * @param ObjectManager $em | |||||
| * @param $email | |||||
| */ | |||||
| public function setEmail(ObjectManager $em, $email) | |||||
| public function setEmail(EntityManagerInterface $em, $email) | |||||
| { | { | ||||
| if ($email != $this->email) { | if ($email != $this->email) { | ||||
| if (!Utils::validateEmail($em, $email)) { | if (!Utils::validateEmail($em, $email)) { | ||||
| @@ -215,34 +202,21 @@ class EntUser implements IEntity, UserInterface, PasswordAuthenticatedUserInterf | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * @param bool|string $password | |||||
| */ | |||||
| public function setPassword($password): void | public function setPassword($password): void | ||||
| { | { | ||||
| $this->password = $password; | $this->password = $password; | ||||
| } | } | ||||
| /** | |||||
| * @param bool $active | |||||
| */ | |||||
| public function setActive(bool $active): void | public function setActive(bool $active): void | ||||
| { | { | ||||
| $this->active = $active; | $this->active = $active; | ||||
| } | } | ||||
| /** | |||||
| * @param mixed $lastname | |||||
| */ | |||||
| public function setLastname($lastname): void | public function setLastname($lastname): void | ||||
| { | { | ||||
| $this->lastname = $lastname; | $this->lastname = $lastname; | ||||
| } | } | ||||
| /** | |||||
| * @param string $firstname | |||||
| * @return EntUser | |||||
| */ | |||||
| public function setFirstname(string $firstname): self | public function setFirstname(string $firstname): self | ||||
| { | { | ||||
| $this->firstname = $firstname; | $this->firstname = $firstname; | ||||
| @@ -250,25 +224,16 @@ class EntUser implements IEntity, UserInterface, PasswordAuthenticatedUserInterf | |||||
| return $this; | return $this; | ||||
| } | } | ||||
| /** | |||||
| * @param bool $visible | |||||
| */ | |||||
| public function setVisible(bool $visible): void | public function setVisible(bool $visible): void | ||||
| { | { | ||||
| $this->visible = $visible; | $this->visible = $visible; | ||||
| } | } | ||||
| /** | |||||
| * Returns whether this user is on higher user role level than given user to compare with | |||||
| * @param EntUser $compareUser | |||||
| * @return bool | |||||
| */ | |||||
| public function isHigherUser(EntUser $compareUser) | |||||
| private function getTranslatedRole(): string | |||||
| { | { | ||||
| return EntUserType::isHigherUserType($this->user_type_id, $compareUser->getUserTypeId()); | |||||
| return $this->isAdmin() ? 'Admin' : 'User'; | |||||
| } | } | ||||
| /** | /** | ||||
| * Sets client data | * Sets client data | ||||
| * @param EntityManagerInterface $em | * @param EntityManagerInterface $em | ||||
| @@ -296,6 +261,8 @@ class EntUser implements IEntity, UserInterface, PasswordAuthenticatedUserInterf | |||||
| 'lastname' => $this->lastname, | 'lastname' => $this->lastname, | ||||
| 'active' => $this->active, | 'active' => $this->active, | ||||
| 'visible' => $this->visible, | 'visible' => $this->visible, | ||||
| 'roles' => $this->getRoles(), | |||||
| 'v_translated_role' => $this->getTranslatedRole() | |||||
| ]; | ]; | ||||
| } | } | ||||
| @@ -3,7 +3,7 @@ | |||||
| namespace App\EventListener; | namespace App\EventListener; | ||||
| use App\Entity\EntUser; | |||||
| use App\Entity\User; | |||||
| use App\Utils\Tools; | use App\Utils\Tools; | ||||
| use Doctrine\ORM\EntityManager; | use Doctrine\ORM\EntityManager; | ||||
| use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | ||||
| @@ -9,7 +9,7 @@ | |||||
| namespace App\EventListener; | namespace App\EventListener; | ||||
| use App\Entity\EntUser; | |||||
| use App\Entity\User; | |||||
| use App\Entity\IFace\IEntity; | use App\Entity\IFace\IEntity; | ||||
| use Doctrine\Common\EventSubscriber; | use Doctrine\Common\EventSubscriber; | ||||
| use Doctrine\ORM\EntityManager; | use Doctrine\ORM\EntityManager; | ||||
| @@ -7,7 +7,7 @@ | |||||
| */ | */ | ||||
| namespace App\Security; | namespace App\Security; | ||||
| use App\Entity\EntUser; | |||||
| use App\Entity\User; | |||||
| use App\Utils\Config; | use App\Utils\Config; | ||||
| use Doctrine\ORM\EntityManager; | use Doctrine\ORM\EntityManager; | ||||
| use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
| @@ -23,13 +23,10 @@ use Symfony\Component\Security\Http\Authenticator\Passport\Passport; | |||||
| class JsonAuthenticator extends AbstractAuthenticator | class JsonAuthenticator extends AbstractAuthenticator | ||||
| { | { | ||||
| const LOGIN_FAILED = 0; | |||||
| const LOGIN_SUCCESS = 1; | |||||
| private $em; | |||||
| private EntityManagerInterface $em; | |||||
| /** @var $user EntUser */ | |||||
| private $user; | |||||
| private Passport $passport; | |||||
| /** | /** | ||||
| * JsonAuthenticator constructor. | * JsonAuthenticator constructor. | ||||
| @@ -58,18 +55,21 @@ class JsonAuthenticator extends AbstractAuthenticator | |||||
| { | { | ||||
| $email = $request->request->get('email'); | $email = $request->request->get('email'); | ||||
| $password = $request->request->get('password'); | $password = $request->request->get('password'); | ||||
| return new Passport( | |||||
| $passport = new Passport( | |||||
| new UserBadge($email), | new UserBadge($email), | ||||
| new PasswordCredentials($password) | new PasswordCredentials($password) | ||||
| ); | ); | ||||
| $this->passport = $passport; | |||||
| return $passport; | |||||
| } | } | ||||
| public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response | public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response | ||||
| { | { | ||||
| // on success, let the request continue | // on success, let the request continue | ||||
| /** @var User $user */ | |||||
| $user = $this->passport->getUser(); | |||||
| $data = array('message' => 'logged in successfully', | $data = array('message' => 'logged in successfully', | ||||
| 'isLoggedIn' => self::LOGIN_SUCCESS, | |||||
| 'user' => $this->user->clientMapper($this->em), | |||||
| 'user' => $user->clientMapper($this->em), | |||||
| 'config' => Config::getConfig($this->em), | 'config' => Config::getConfig($this->em), | ||||
| ); | ); | ||||
| return new JsonResponse($data, Response::HTTP_ACCEPTED); | return new JsonResponse($data, Response::HTTP_ACCEPTED); | ||||
| @@ -77,16 +77,7 @@ class JsonAuthenticator extends AbstractAuthenticator | |||||
| public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response | public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response | ||||
| { | { | ||||
| $data = array( | |||||
| 'message' => strtr($exception->getMessageKey(), $exception->getMessageData()), | |||||
| 'isLoggedIn' => self::LOGIN_FAILED, | |||||
| 'user' => null, | |||||
| 'config' => null, | |||||
| // or to translate this message | |||||
| //$this->translator->trans($exception->getMessageKey(), $exception->getMessageData()) | |||||
| ); | |||||
| return new JsonResponse($data, Response::HTTP_FORBIDDEN); | |||||
| return new JsonResponse(null, Response::HTTP_UNAUTHORIZED); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -9,6 +9,9 @@ | |||||
| namespace App\Utils; | namespace App\Utils; | ||||
| use App\Entity\Country; | |||||
| use App\Entity\MeetingType; | |||||
| use App\Entity\User; | |||||
| use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
| class Config | class Config | ||||
| @@ -21,9 +24,9 @@ class Config | |||||
| public static function getConfig(EntityManagerInterface $em) | public static function getConfig(EntityManagerInterface $em) | ||||
| { | { | ||||
| return [ | return [ | ||||
| 'users' => Utils::clientMap($em, $em->getRepository('App:EntUser')->findBy(['visible' => true])), | |||||
| 'meeting_types' => Utils::clientMap($em, $em->getRepository('App:EntMeetingType')->findAll()), | |||||
| 'countries' => Utils::clientMap($em, $em->getRepository('App:EntCountry')->findAll()), | |||||
| 'users' => Utils::clientMap($em, $em->getRepository(User::class)->findBy(['visible' => true])), | |||||
| 'meeting_types' => Utils::clientMap($em, $em->getRepository(MeetingType::class)->findAll()), | |||||
| 'countries' => Utils::clientMap($em, $em->getRepository(Country::class)->findAll()), | |||||
| ]; | ]; | ||||
| } | } | ||||
| @@ -10,7 +10,10 @@ namespace App\Utils; | |||||
| use App\Entity\IFace\IEntity; | use App\Entity\IFace\IEntity; | ||||
| use App\Entity\User; | |||||
| use Doctrine\DBAL\DriverManager; | use Doctrine\DBAL\DriverManager; | ||||
| use Doctrine\ORM\EntityManager; | |||||
| use Doctrine\ORM\EntityManagerInterface; | |||||
| use Symfony\Component\Mailer\MailerInterface; | use Symfony\Component\Mailer\MailerInterface; | ||||
| use Symfony\Component\Mime\Email; | use Symfony\Component\Mime\Email; | ||||
| use function Couchbase\defaultDecoder; | use function Couchbase\defaultDecoder; | ||||
| @@ -116,8 +119,6 @@ class Utils | |||||
| /** | /** | ||||
| * Checks email format | * Checks email format | ||||
| * @param $email | |||||
| * @return bool | |||||
| */ | */ | ||||
| public static function isValidEmail($email) | public static function isValidEmail($email) | ||||
| { | { | ||||
| @@ -126,33 +127,22 @@ class Utils | |||||
| /** | /** | ||||
| * Checks if valid gender | * Checks if valid gender | ||||
| * @param $gender | |||||
| * @return bool | |||||
| */ | */ | ||||
| public static function isValidGender($gender) | public static function isValidGender($gender) | ||||
| { | { | ||||
| return $gender == self::GENDER_MALE || $gender == self::GENDER_FEMALE || $gender == self::GENDER_DIVERSE; | return $gender == self::GENDER_MALE || $gender == self::GENDER_FEMALE || $gender == self::GENDER_DIVERSE; | ||||
| } | } | ||||
| /** | |||||
| * Checks if an email exists in users, persons or locations | |||||
| * @param ObjectManager $em | |||||
| * @param $email | |||||
| * @return bool | |||||
| */ | |||||
| public static function emailUserExists(ObjectManager $em, $email) | |||||
| public static function emailUserExists(EntityManagerInterface $em, $email) | |||||
| { | { | ||||
| $existingUserEmail = $em->getRepository('App:EntUser')->findOneBy(['email' => $email]); | |||||
| $existingUserEmail = $em->getRepository(User::class)->findOneBy(['email' => $email]); | |||||
| return !is_null($existingUserEmail); | return !is_null($existingUserEmail); | ||||
| } | } | ||||
| /** | /** | ||||
| * Validates email and checks existence | * Validates email and checks existence | ||||
| * @param ObjectManager $em | |||||
| * @param $email | |||||
| * @return bool | |||||
| */ | */ | ||||
| public static function validateEmail(ObjectManager $em, $email) | |||||
| public static function validateEmail(EntityManagerInterface $em, $email) | |||||
| { | { | ||||
| return self::isValidEmail($email) && !self::emailUserExists($em, $email); | return self::isValidEmail($email) && !self::emailUserExists($em, $email); | ||||
| } | } | ||||
| @@ -165,8 +155,8 @@ class Utils | |||||
| public static function isExcelFile(UploadedFile $uploadedFile) | public static function isExcelFile(UploadedFile $uploadedFile) | ||||
| { | { | ||||
| // Check client mime type | // Check client mime type | ||||
| return $uploadedFile->getClientMimeType() == 'application/vnd.ms-excel' || | |||||
| $uploadedFile->getClientMimeType() == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; | |||||
| return $uploadedFile->getClientMimeType() === 'application/vnd.ms-excel' || | |||||
| $uploadedFile->getClientMimeType() === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -262,12 +252,8 @@ class Utils | |||||
| /** | /** | ||||
| * Returns array of client mappable items | * Returns array of client mappable items | ||||
| * @param ObjectManager $em | |||||
| * @param $arr | |||||
| * @param bool $fullMapping | |||||
| * @return array | |||||
| */ | */ | ||||
| public static function clientMap(ObjectManager $em, $arr, $fullMapping = false) | |||||
| public static function clientMap(EntityManagerInterface $em, $arr, $fullMapping = false) | |||||
| { | { | ||||
| $res = []; | $res = []; | ||||
| foreach ($arr as $key => $value) { | foreach ($arr as $key => $value) { | ||||
| @@ -283,9 +269,6 @@ class Utils | |||||
| /** | /** | ||||
| * Returns array with file path info | * Returns array with file path info | ||||
| * @param $filePath | |||||
| * @param $fileName | |||||
| * @return array | |||||
| */ | */ | ||||
| public static function getFilePathArray($filePath, $fileName) | public static function getFilePathArray($filePath, $fileName) | ||||
| { | { | ||||
| @@ -297,10 +280,6 @@ class Utils | |||||
| /** | /** | ||||
| * Creates a zip file of given files | * Creates a zip file of given files | ||||
| * @param $zipFilePath | |||||
| * @param $zipFileName | |||||
| * @param $files | |||||
| * @return string | |||||
| */ | */ | ||||
| public static function createZipFile($zipFilePath, $zipFileName, $files) | public static function createZipFile($zipFilePath, $zipFileName, $files) | ||||
| { | { | ||||
| @@ -317,10 +296,6 @@ class Utils | |||||
| /** | /** | ||||
| * Creates a zip file from folder and optionally excluded files | * Creates a zip file from folder and optionally excluded files | ||||
| * @param $zipFilePath | |||||
| * @param $zipFileName | |||||
| * @param array $skippedFileNames | |||||
| * @param bool $includeZipPathFolder | |||||
| */ | */ | ||||
| public static function createZipFileFromFolder($zipFilePath, $zipFileName, $skippedFileNames = [], $includeZipPathFolder = false) | public static function createZipFileFromFolder($zipFilePath, $zipFileName, $skippedFileNames = [], $includeZipPathFolder = false) | ||||
| { | { | ||||
| @@ -449,9 +424,11 @@ class Utils | |||||
| public static function copyFolderRecursively($sourcPath, $destinationPath) | public static function copyFolderRecursively($sourcPath, $destinationPath) | ||||
| { | { | ||||
| $dir = opendir($sourcPath); | $dir = opendir($sourcPath); | ||||
| @mkdir($destinationPath); | |||||
| if (!mkdir($destinationPath) && !is_dir($destinationPath)) { | |||||
| throw new \RuntimeException(sprintf('Directory "%s" was not created', $destinationPath)); | |||||
| } | |||||
| while(false !== ( $file = readdir($dir)) ) { | while(false !== ( $file = readdir($dir)) ) { | ||||
| if (( $file != '.' ) && ( $file != '..' )) { | |||||
| if (( $file !== '.' ) && ( $file !== '..' )) { | |||||
| if ( is_dir($sourcPath . '/' . $file) ) { | if ( is_dir($sourcPath . '/' . $file) ) { | ||||
| self::copyFolderRecursively($sourcPath . '/' . $file,$destinationPath . '/' . $file); | self::copyFolderRecursively($sourcPath . '/' . $file,$destinationPath . '/' . $file); | ||||
| } | } | ||||
| @@ -470,7 +447,7 @@ class Utils | |||||
| public static function deleteDirectory($dirPath) { | public static function deleteDirectory($dirPath) { | ||||
| $dir = opendir($dirPath); | $dir = opendir($dirPath); | ||||
| while(false !== ( $file = readdir($dir)) ) { | while(false !== ( $file = readdir($dir)) ) { | ||||
| if (( $file != '.' ) && ( $file != '..' )) { | |||||
| if (( $file !== '.' ) && ( $file !== '..' )) { | |||||
| $full = $dirPath . '/' . $file; | $full = $dirPath . '/' . $file; | ||||
| if ( is_dir($full) ) { | if ( is_dir($full) ) { | ||||
| self::deleteDirectory($full); | self::deleteDirectory($full); | ||||
| @@ -35,6 +35,18 @@ | |||||
| "migrations/.gitignore" | "migrations/.gitignore" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "nelmio/cors-bundle": { | |||||
| "version": "2.3", | |||||
| "recipe": { | |||||
| "repo": "github.com/symfony/recipes", | |||||
| "branch": "main", | |||||
| "version": "1.5", | |||||
| "ref": "6bea22e6c564fba3a1391615cada1437d0bde39c" | |||||
| }, | |||||
| "files": [ | |||||
| "config/packages/nelmio_cors.yaml" | |||||
| ] | |||||
| }, | |||||
| "sensio/framework-extra-bundle": { | "sensio/framework-extra-bundle": { | ||||
| "version": "6.2", | "version": "6.2", | ||||
| "recipe": { | "recipe": { | ||||