diff --git a/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/AddressDetailController.php b/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/AddressDetailController.php
index 9549a8a1a..2b41b337a 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/AddressDetailController.php
+++ b/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/AddressDetailController.php
@@ -13,11 +13,11 @@ use PSC\Shop\OrderBundle\Form\Backend\Upload\DeleteType;
use PSC\System\SettingsBundle\Document\LogEntry;
use PSC\System\SettingsBundle\Service\History;
use PSC\System\SettingsBundle\Service\Log;
+use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Attribute\Route;
-use Symfony\Bridge\Twig\Attribute\Template;
-use Symfony\Component\HttpFoundation\Request;
class AddressDetailController extends AbstractController
{
@@ -26,6 +26,7 @@ class AddressDetailController extends AbstractController
*/
private Log $logService;
private History $historyService;
+
public function __construct(Log $logService, History $historyService)
{
$this->logService = $logService;
@@ -51,16 +52,16 @@ class AddressDetailController extends AbstractController
DocumentManager $documentManager,
SessionInterface $session,
\PSC\System\SettingsBundle\Service\Shop $shopService,
- $uuid = ""
+ $uuid = '',
) {
/** @var ContactAddress $contact */
$contactAddress = $entityManager
- ->getRepository('PSC\Shop\EntityBundle\Entity\ContactAddress')
- ->findOneBy(array('uuid' => $uuid));
+ ->getRepository('PSC\Shop\EntityBundle\Entity\ContactAddress')
+ ->findOneBy(array('uuid' => $uuid));
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
$contactAddressDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\ContactAddress')
- ->findOneBy(array('uid' => (string)$contactAddress->getUid()));
+ ->findOneBy(array('uid' => (string) $contactAddress->getUid()));
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
$selectedShop = $shopService->getSelectedShop();
/** @var Contact $contact */
@@ -68,7 +69,7 @@ class AddressDetailController extends AbstractController
/** @var \PSC\Shop\EntityBundle\Document\Contact $contactDoc */
$contactDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Contact')
- ->findOneBy(array('uid' => (string)$contact->getId()));
+ ->findOneBy(array('uid' => (string) $contact->getId()));
if (!$request->isMethod('POST') && $contactAddressDoc) {
$contactAddress->setKundenNr($contactAddressDoc->getKundenNr());
$contactAddress->setHomepage($contactAddressDoc->getHomepage());
@@ -77,7 +78,7 @@ class AddressDetailController extends AbstractController
} elseif (!$contactAddressDoc) {
if (!$contactDoc) {
$contactDoc = new \PSC\Shop\EntityBundle\Document\Contact();
- $contactDoc->setKundenNr("");
+ $contactDoc->setKundenNr('');
$contactDoc->setUid($contact->getId());
$documentManager->persist($contactDoc);
}
@@ -99,13 +100,25 @@ class AddressDetailController extends AbstractController
$contactAddressDoc->setHomepage($contactAddress->getHomepage());
$contactAddressDoc->setSteuerId($contactAddress->getSteuerId());
$contactAddressDoc->setLId($contactAddress->getLId());
- $this->historyService->createHistoryEntry(new PSCHistory((string)$contactAddress->getUid()), $contactAddress, $contactAddressDoc);
+ $this->historyService->createHistoryEntry(
+ new PSCHistory((string) $contactAddress->getUid()),
+ $contactAddress,
+ $contactAddressDoc,
+ );
$entityManager->persist($contactAddress);
$entityManager->flush();
$documentManager->persist($contactAddressDoc);
$documentManager->flush();
$session->getFlashBag()->add('success', 'Address has been updated!');
- $this->logService->createLogEntry($selectedShop, $this->getUser(), LogEntry::INFO, PSCShopContactBundle::class, $contactAddress->getUuid(), "Address has been updated", ['contact' => $contact->getEmail()]);
+ $this->logService->createLogEntry(
+ $selectedShop,
+ $this->getUser(),
+ LogEntry::INFO,
+ PSCShopContactBundle::class,
+ $contactAddress->getUuid(),
+ 'Address has been updated',
+ ['contact' => $contact->getEmail()],
+ );
return $this->redirectToRoute('psc_shop_contact_backend_edit', array('uuid' => $contact->getUuid()));
}
@@ -113,7 +126,7 @@ class AddressDetailController extends AbstractController
'form' => $form->createView(),
'contact' => $contact,
'contactAddress' => $contactAddress,
- 'changes' => $this->historyService->getHistory(new PSCHistory(), (string)$contactAddress->getUid())
+ 'changes' => $this->historyService->getHistory(new PSCHistory(), (string) $contactAddress->getUid()),
);
}
@@ -136,9 +149,8 @@ class AddressDetailController extends AbstractController
DocumentManager $documentManager,
SessionInterface $session,
\PSC\System\SettingsBundle\Service\Shop $shopService,
- $contactUUID = ""
+ $contactUUID = '',
) {
-
/** @var Contact $contact */
$contact = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Contact')
@@ -154,7 +166,7 @@ class AddressDetailController extends AbstractController
/** @var \PSC\Shop\EntityBundle\Document\Contact $contactDoc */
$contactDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Contact')
- ->findOneBy(array('uid' => (string)$contact->getId()));
+ ->findOneBy(array('uid' => (string) $contact->getId()));
$form = $this->createForm(ContactAddressType::class, $contactAddress);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
@@ -168,15 +180,22 @@ class AddressDetailController extends AbstractController
$documentManager->persist($contactAddressDoc);
$documentManager->flush();
$session->getFlashBag()->add('success', 'Address has been created!');
- $this->logService->createLogEntry($selectedShop, $this->getUser(), LogEntry::INFO, PSCShopContactBundle::class, $contactAddress->getUuid(), "Address has been created", ['contact' => $contact->getEmail()]);
+ $this->logService->createLogEntry(
+ $selectedShop,
+ $this->getUser(),
+ LogEntry::INFO,
+ PSCShopContactBundle::class,
+ $contactAddress->getUuid(),
+ 'Address has been created',
+ ['contact' => $contact->getEmail()],
+ );
return $this->redirectToRoute('psc_shop_contact_backend_edit', array('uuid' => $contact->getUuid()));
}
return array(
'form' => $form->createView(),
'contact' => $contact,
- 'contactAddress' => $contactAddress
-
+ 'contactAddress' => $contactAddress,
);
}
@@ -191,7 +210,7 @@ class AddressDetailController extends AbstractController
* @return array|\Symfony\Component\HttpFoundation\RedirectResponse
* @throws \Doctrine\ODM\MongoDB\MongoDBException
*/
- #[Route(path: '/edit/delete/{uuid}', name: 'psc_shop_contact_backend_address_detail_delete')]
+ #[Route(path: '/addressdetail/delete/{uuid}', name: 'psc_shop_contact_backend_address_detail_delete')]
#[Template('@PSCShopContact/backend/addressdetail/delete.html.twig')]
public function deleteAction(
Request $request,
@@ -199,9 +218,8 @@ class AddressDetailController extends AbstractController
DocumentManager $documentManager,
SessionInterface $session,
\PSC\System\SettingsBundle\Service\Shop $shopService,
- $uuid
+ $uuid,
) {
-
/** @var ContactAddress $contactAddress */
$contactAddress = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\ContactAddress')
@@ -209,7 +227,7 @@ class AddressDetailController extends AbstractController
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
$contactAddressDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\ContactAddress')
- ->findOneBy(array('uid' => (string)$contactAddress->getUid()));
+ ->findOneBy(array('uid' => (string) $contactAddress->getUid()));
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
$selectedShop = $shopService->getSelectedShop();
$form = $this->createForm(DeleteType::class);
@@ -226,17 +244,24 @@ class AddressDetailController extends AbstractController
}
$session->getFlashBag()->add('success', 'Address has been deleted!');
- $this->logService->createLogEntry($selectedShop, $this->getUser(), LogEntry::INFO, PSCShopContactBundle::class, $uuid, "Address has been deleted", ['contact' => $email]);
+ $this->logService->createLogEntry(
+ $selectedShop,
+ $this->getUser(),
+ LogEntry::INFO,
+ PSCShopContactBundle::class,
+ $uuid,
+ 'Address has been deleted',
+ ['contact' => $email],
+ );
return $this->redirectToRoute('psc_shop_contact_backend_edit', array('uuid' => $uuid));
}
return $this->redirectToRoute('psc_shop_contact_backend_edit', array('uuid' => $uuid));
}
-
return array(
'address' => $contactAddress,
'contact' => $contactAddress->getContact(),
- 'form' => $form->createView()
+ 'form' => $form->createView(),
);
}
}
diff --git a/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php b/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php
index d31f7aa8f..2640ee0bb 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php
+++ b/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php
@@ -557,6 +557,95 @@ class EditController extends AbstractController
);
}
+ #[Route(path: '/edit/delete/{uuid}', name: 'psc_shop_contact_backend_delete')]
+ #[Template('@PSCShopContact/backend/edit/delete.html.twig')]
+ public function deleteAction(
+ Request $request,
+ \PSC\System\SettingsBundle\Service\Shop $shopService,
+ EntityManagerInterface $entityManager,
+ DocumentManager $documentManager,
+ SessionInterface $session,
+ $uuid = ""
+ ) {
+ /** @var Contact $contact */
+ $contact = $entityManager
+ ->getRepository('PSC\Shop\EntityBundle\Entity\Contact')
+ ->findOneBy(array('uuid' => $uuid));
+
+ /** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
+ $selectedShop = $shopService->getSelectedShop();
+
+ // Check if orders exist for this contact
+ $orderCount = $entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Order')
+ ->createQueryBuilder('o')
+ ->select('count(o.uid)')
+ ->leftJoin('o.contact', 'c')
+ ->andWhere('c.uid = :contact_id')
+ ->setParameter('contact_id', $contact->getUid())
+ ->getQuery()
+ ->getSingleScalarResult();
+
+ $hasOrders = (int)$orderCount > 0;
+
+ $form = $this->createForm(AnonymType::class);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ if (!$hasOrders && $form->getClickedButton()->getName() == 'yes') {
+ $email = $contact->getEmail();
+
+ // Remove contact addresses
+ $contactAddresses = $entityManager
+ ->getRepository('PSC\Shop\EntityBundle\Entity\ContactAddress')
+ ->findBy(array('contact' => $contact));
+
+ foreach ($contactAddresses as $contactAddress) {
+ $contactAddressDoc = $documentManager
+ ->getRepository('PSC\Shop\EntityBundle\Document\ContactAddress')
+ ->findOneBy(array('uid' => (string)$contactAddress->getUid()));
+ $entityManager->remove($contactAddress);
+ if ($contactAddressDoc) {
+ $documentManager->remove($contactAddressDoc);
+ }
+ }
+
+ // Remove shop contacts
+ $shopContacts = $entityManager
+ ->getRepository('PSC\Shop\EntityBundle\Entity\ShopContact')
+ ->findBy(array('contact' => $contact));
+
+ foreach ($shopContacts as $shopContact) {
+ $entityManager->remove($shopContact);
+ }
+
+ // Remove MongoDB document
+ $contactDoc = $documentManager
+ ->getRepository('PSC\Shop\EntityBundle\Document\Contact')
+ ->findOneBy(array('uid' => (string)$contact->getId()));
+
+ $entityManager->remove($contact);
+ $entityManager->flush();
+
+ if ($contactDoc) {
+ $documentManager->remove($contactDoc);
+ $documentManager->flush();
+ }
+
+ $session->getFlashBag()->add('success', 'Contact \'' . $email . '\' has been deleted!');
+ $this->logService->createLogEntry($selectedShop, $this->getUser(), LogEntry::INFO, PSCShopContactBundle::class, $email, "Contact deleted");
+ }
+
+ return $this->redirectToRoute('psc_shop_contact_backend_list');
+ }
+
+ return array(
+ 'contact' => $contact,
+ 'form' => $form->createView(),
+ 'hasOrders' => $hasOrders,
+ 'orderCount' => (int)$orderCount,
+ );
+ }
+
/**
* @param array... $arrayCollections
* @return ArrayCollection
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_delete_contact.de.yaml b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_delete_contact.de.yaml
new file mode 100644
index 000000000..a41b72d2e
--- /dev/null
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_delete_contact.de.yaml
@@ -0,0 +1,9 @@
+customers: Kunden
+delete: Löschen
+deleteCustomer: Kunde löschen
+Doyoureally: Sind Sie sicher, dass Sie diesen Kunden löschen möchten?
+hasOrders: Dieser Kunde kann nicht gelöscht werden, da noch %count% Aufträge vorhanden sind.
+cannotBeUndone: Diese Aktion kann nicht rückgängig gemacht werden
+back: Zurück
+yes: Ja
+no: Nein
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_delete_contact.en.yaml b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_delete_contact.en.yaml
new file mode 100644
index 000000000..81fd6c55d
--- /dev/null
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_delete_contact.en.yaml
@@ -0,0 +1,9 @@
+customers: Customer
+delete: Delete
+deleteCustomer: Delete customer
+Doyoureally: Are you sure you want to delete this customer?
+hasOrders: This customer cannot be deleted because there are still %count% orders.
+cannotBeUndone: This action cannot be undone
+back: Back
+yes: Yes
+no: No
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.de.yaml b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.de.yaml
index 2d52a0426..27134c490 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.de.yaml
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.de.yaml
@@ -61,6 +61,7 @@ Extended: Erweitert
Save: Speichern
Anonymize: Anonymisieren
+delete: Löschen
back: Zurück
Address: Adressen
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.en.yaml b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.en.yaml
index 91ee50997..bfe1ad940 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.en.yaml
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_edit.en.yaml
@@ -55,6 +55,7 @@ Extended: Extended
Save: Save
Anonymize: Anonymize
+delete: Delete
back: Back
Address: Address
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.de.yaml b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.de.yaml
index 4a3eb4be5..2507cf75f 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.de.yaml
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.de.yaml
@@ -14,5 +14,6 @@ virtual: Gast
yes: Ja
no: Nein
edit: Bearbeiten
+delete: Löschen
Loginname: Login/Email
shops: Weitere Shops
\ No newline at end of file
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.en.yaml b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.en.yaml
index f5bfec4d7..b96230846 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.en.yaml
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/translations/core_contact_list.en.yaml
@@ -14,5 +14,6 @@ virtual: Guest
yes: Yes
no: No
edit: To Edit
+delete: Delete
Loginname: Login/Email
shops: Shops
\ No newline at end of file
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/edit/delete.html.twig b/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/edit/delete.html.twig
new file mode 100644
index 000000000..055806c4a
--- /dev/null
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/edit/delete.html.twig
@@ -0,0 +1,108 @@
+{% extends 'backend_tailwind_base.html.twig' %}
+{% form_theme form 'form_div_layout_tailwind.html.twig' %}
+{% trans_default_domain 'core_contact_delete_contact' %}
+
+{% block header %}
+
+
+
+ {{'customers'|trans}} {{'delete'|trans}}
+
+
+
+{% endblock %}
+
+{% block body %}
+
+
+ {# Delete Confirmation Card #}
+
+
+ {# Card Header #}
+
+
+
+
+ {{'deleteCustomer'|trans}}?
+
+
+
+
+ {# Card Body #}
+
+
+ {% if hasOrders %}
+
+
+
+
+ {{ 'hasOrders'|trans({'%count%': orderCount}) }}
+
+
+
+ {% else %}
+
+ {{'Doyoureally'|trans}}
+
+ {% endif %}
+
+
+
+ {{ contact.username }}
+
+
+
+ {% if not hasOrders %}
+
+
+
+
+ {{'cannotBeUndone'|trans}}.
+
+
+
+ {% endif %}
+
+
+
+ {# Card Footer with Actions #}
+ {% if not hasOrders %}
+
+ {{ form_start(form) }}
+
+ {{ form_widget(form.no, {
+ attr: {
+ class: 'inline-flex items-center justify-center py-2 gap-2 font-medium rounded-md px-4 text-sm text-psc-600 border border-psc-500 bg-white hover:bg-gray-50 hover:ring-2 hover:ring-psc-500 hover:ring-offset-1 shadow-sm'
+ },
+ label: 'no'|trans
+ }) }}
+ {{ form_widget(form.yes, {
+ attr: {
+ class: 'inline-flex items-center justify-center py-2 gap-2 font-medium rounded-md px-4 text-sm text-white shadow-lg bg-red-500 hover:bg-red-600 hover:ring-2 hover:ring-red-500 hover:ring-offset-1'
+ },
+ label: 'yes'|trans
+ }) }}
+
+ {{ form_end(form) }}
+
+ {% endif %}
+
+
+
+
+{% endblock %}
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/edit/edit.html.twig b/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/edit/edit.html.twig
index 06028993c..c824d5557 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/edit/edit.html.twig
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/edit/edit.html.twig
@@ -21,6 +21,7 @@
diff --git a/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/list/index.html.twig b/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/list/index.html.twig
index 073b5fe61..d12ccc363 100755
--- a/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/list/index.html.twig
+++ b/src/new/src/PSC/Shop/ContactBundle/Resources/views/backend/list/index.html.twig
@@ -125,6 +125,11 @@
+