Browse Source

Suppression utilisateur

packProduct
Fabien Normand 2 years ago
parent
commit
62852af723
12 changed files with 111 additions and 14 deletions
  1. +0
    -1
      Controller/AbstractAdminController.php
  2. +65
    -4
      Controller/User/UserAdminController.php
  3. +1
    -0
      Factory/Credit/CreditHistoryFactory.php
  4. +2
    -2
      Model/Address/AddressModel.php
  5. +19
    -1
      Model/Credit/CreditHistoryModel.php
  6. +1
    -1
      Model/File/DocumentModel.php
  7. +1
    -0
      Model/Reduction/ReductionCreditModel.php
  8. +1
    -1
      Model/Section/SectionModel.php
  9. +1
    -1
      Model/User/UserMerchantModel.php
  10. +1
    -1
      Model/User/UserModel.php
  11. +8
    -1
      Repository/User/UserMerchantStore.php
  12. +11
    -1
      Resources/translations/admin.fr.yaml

+ 0
- 1
Controller/AbstractAdminController.php View File

@@ -68,7 +68,6 @@ abstract class AbstractAdminController extends SovAbstractAdminController
$filteredValue = ['value' => $context->getRequest()->query->get('q')];
$filterManager->applyFilter($repositoryQuery, $field, $filteredValue);
$repositoryQuery->select('.' . $autocompleteContext['propertyName']);
//dump($repositoryQuery->getQueryBuilder()->getQuery()->getDQL());

$responses = array();
foreach ($repositoryQuery->find() as $result) {

+ 65
- 4
Controller/User/UserAdminController.php View File

@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController;
use Lc\SovBundle\Definition\ActionDefinition;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class UserAdminController extends SovUserAdminController
@@ -17,7 +18,6 @@ abstract class UserAdminController extends SovUserAdminController

public function getRepositoryQuery(): RepositoryQueryInterface
{
dump($this->container->get($this->getContainerFqcn()));
return $this->container->get($this->getContainerFqcn())->getRepositoryQuery();
}

@@ -29,11 +29,11 @@ abstract class UserAdminController extends SovUserAdminController
public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void
{
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action){
if($action->getName() == ActionDefinition::SWITCH_USER){
foreach ($entity->getActions() as $action) {
if ($action->getName() == ActionDefinition::SWITCH_USER) {
$sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault();

$url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug()));
$url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section' => $sectionDefault->getSlug()));
$action->setLinkUrl($url);
}
}
@@ -42,6 +42,67 @@ abstract class UserAdminController extends SovUserAdminController
}


public function getDeleteUserWarningMessageList(UserInterface $user): array
{
$warningMessages = parent::getDeleteUserWarningMessageList($user);

foreach ($this->getUserMerchantContainer()->getStore()->getByUserOutOfContext($user) as $userMerchant) {
if ($this->getUserMerchantContainer()->getSolver()->isCreditActive($userMerchant) && $userMerchant->getCredit() != 0) {
$warningMessages['danger'][] = $this->getTranslatorAdmin()->transFlashMessage('error', 'deleteHasCredit', 'User', array('%merchant%' => $userMerchant->getMerchant()));
}
}

foreach ($this->getReductionCatalogContainer()->getStore()->getByUserOutOfContext($user) as $reductionCatalog) {
$warningMessages['danger'][] = $this->getTranslatorAdmin()->transFlashMessage(
'error',
'deleteHasReductionCatalog',
'User',
array(
'%merchant%' => $reductionCatalog->getMerchant(),
'%id%' => $reductionCatalog->getId()
)
);
}

foreach ($this->getReductionCartContainer()->getStore()->getByUserOutOfContext($user) as $reductionCart) {
$warningMessages['danger'][] = $this->getTranslatorAdmin()->transFlashMessage(
'error',
'deleteHasReductionCart',
'User',
array(
'%merchant%' => $reductionCart->getMerchant(),
'%id%' => $reductionCart->getId()
)
);
}

foreach ($this->getReductionCreditContainer()->getStore()->getReductionCreditByUserOutOfContext($user) as $reductionCredit) {
$warningMessages['warning'][] = $this->getTranslatorAdmin()->transFlashMessage(
'error',
'deleteHasReductionCredit',
'User',
array(
'%merchant%' => $reductionCredit->getMerchant(),
'%id%' => $reductionCredit->getId()
)
);
}

foreach ($this->getReductionCreditContainer()->getStore()->getReductionGiftByUserOutOfContext($user) as $reductionGift) {
$warningMessages['warning'][] = $this->getTranslatorAdmin()->transFlashMessage(
'error',
'deleteHasReductionGift',
'User',
array(
'%merchant%' => $reductionGift->getMerchant(),
'%id%' => $reductionGift->getId()
)
);
}


return $warningMessages;
}


}

+ 1
- 0
Factory/Credit/CreditHistoryFactory.php View File

@@ -24,6 +24,7 @@ class CreditHistoryFactory extends AbstractFactory
$class = CreditHistoryContainer::getEntityFqcn();
$creditHistory = new $class;
$creditHistory->setUserMerchant($userMerchant) ;
$creditHistory->setMerchant($userMerchant->getMerchant()) ;

return $creditHistory;
}

+ 2
- 2
Model/Address/AddressModel.php View File

@@ -118,12 +118,12 @@ abstract class AddressModel extends AbstractLightEntity implements StatusInterfa
protected $comment;

/**
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleInterface", mappedBy="address", cascade={"persist", "remove"})
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleInterface", mappedBy="address", cascade={"persist"})
*/
protected $pointSale;

/**
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", mappedBy="address", cascade={"persist", "remove"})
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", mappedBy="address", cascade={"persist"})
*/
protected $merchant;


+ 19
- 1
Model/Credit/CreditHistoryModel.php View File

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Model\Credit;

use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\PayoffTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderPaymentInterface;
use Lc\CaracoleBundle\Model\Order\OrderRefundInterface;
use Lc\CaracoleBundle\Doctrine\Extension\PayoffInterface;
@@ -34,10 +35,16 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", inversedBy="creditHistories")
* @ORM\JoinColumn(nullable=true, )
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
protected $userMerchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderPaymentInterface", cascade={"persist"})
*/
@@ -89,6 +96,17 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI

return $this;
}
public function getMerchant(): MerchantInterface
{
return $this->merchant;
}

public function setMerchant(MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getOrderPayment(): ?OrderPaymentInterface
{

+ 1
- 1
Model/File/DocumentModel.php View File

@@ -82,7 +82,7 @@ abstract class DocumentModel extends AbstractFullEntity implements FilterMerchan
protected $orderShops;

/**
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderRefundInterface", mappedBy="document", cascade={"persist"})
*/
protected $orderRefund;


+ 1
- 0
Model/Reduction/ReductionCreditModel.php View File

@@ -56,6 +56,7 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc

/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
protected $owner;


+ 1
- 1
Model/Section/SectionModel.php View File

@@ -68,7 +68,7 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant
protected $productCategories;

/**
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="section", orphanRemoval=true)
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="section")
*/
protected $news;


+ 1
- 1
Model/User/UserMerchantModel.php View File

@@ -45,7 +45,7 @@ abstract class UserMerchantModel implements FilterMerchantInterface, EntityInter
protected $creditActive = false;

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface", mappedBy="userMerchant", cascade={"remove"})
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface", mappedBy="userMerchant")
*/
protected $creditHistories;


+ 1
- 1
Model/User/UserModel.php View File

@@ -65,7 +65,7 @@ abstract class UserModel extends SovUserModel
protected $userMerchants;

/**
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface", mappedBy="users", orphanRemoval=true)
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface", mappedBy="users")
*/
protected $reductionCredits;


+ 8
- 1
Repository/User/UserMerchantStore.php View File

@@ -52,5 +52,12 @@ class UserMerchantStore extends AbstractStore
$userMerchant = $this->getOneByUser($user, $query);
return $this->userMerchantSolver->isCreditActive($userMerchant);
}

public function getByUserOutOfContext(UserInterface $user, $query = null): ?array
{
$query = $this->createQuery($query);
$query->filterByUser($user);
return $query->find();

}
}

+ 11
- 1
Resources/translations/admin.fr.yaml View File

@@ -76,7 +76,8 @@ entity:
boxes:
visitor: Visiteur
user: Utilisateur

UserPointSale:
label_plurial: Liens avec une ambassade
PointSale:
label: Point de vente
label_plurial: Points de vente
@@ -95,6 +96,7 @@ entity:
orderAmountMin: Montant minimum de commande

Address:
label_plurial: Adresses
fields:
type: Type
typeOptions:
@@ -147,6 +149,14 @@ entity:
countOrder: Commandes
totalSpent: Ventes
lastLogin: Dernière connexion
flashes:
error:
deleteHasCredit: "L'utilisateur possède du crédit sur <strong>%merchant%</strong>, débiter son compte pour pouvoir le supprimer"
deleteHasReductionCatalog: "L'utilisateur possède une réduction catalogue sur %merchant%, supprimer ou modifier cette réduction pour pouvoir le supprimer<br /> <strong>Réduction catalogue : #%id% sur %merchant%</strong>"
deleteHasReductionCart: "L'utilisateur possède une réduction panier sur %merchant%, supprimer ou modifier cette réduction pour pouvoir le supprimer<br /> <strong>Réduction panier : #%id% sur %merchant%</strong>"
deleteHasReductionCredit: "L'utilisateur possède un avoir sur %merchant%, il ne sera pas supprimé mais non attribué<br /> <strong>Avoir : #%id% sur %merchant%</strong>"
deleteHasReductionGift: "L'utilisateur possède un bon cadeau sur %merchant%, il ne sera pas supprimé mais non attribué<br /> <strong>Bon cadeau : #%id% sur %merchant%</strong>"
deleteEntityCascade: "%count% %entity% liés à l'utilisateur seront supprimés"
CreditHistory:
label: Historique de compte prépayé
label_plurial: Historiques de compte prépayé

Loading…
Cancel
Save