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

$filteredValue = ['value' => $context->getRequest()->query->get('q')]; $filteredValue = ['value' => $context->getRequest()->query->get('q')];
$filterManager->applyFilter($repositoryQuery, $field, $filteredValue); $filterManager->applyFilter($repositoryQuery, $field, $filteredValue);
$repositoryQuery->select('.' . $autocompleteContext['propertyName']); $repositoryQuery->select('.' . $autocompleteContext['propertyName']);
//dump($repositoryQuery->getQueryBuilder()->getQuery()->getDQL());


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

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

use Lc\SovBundle\Container\User\UserContainer; use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController; use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController;
use Lc\SovBundle\Definition\ActionDefinition; use Lc\SovBundle\Definition\ActionDefinition;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;


abstract class UserAdminController extends SovUserAdminController abstract class UserAdminController extends SovUserAdminController


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


public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void
{ {
foreach ($entities as $entity) { 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(); $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); $action->setLinkUrl($url);
} }
} }
} }




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

$class = CreditHistoryContainer::getEntityFqcn(); $class = CreditHistoryContainer::getEntityFqcn();
$creditHistory = new $class; $creditHistory = new $class;
$creditHistory->setUserMerchant($userMerchant) ; $creditHistory->setUserMerchant($userMerchant) ;
$creditHistory->setMerchant($userMerchant->getMerchant()) ;


return $creditHistory; return $creditHistory;
} }

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

protected $comment; 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; 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; protected $merchant;



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



use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\PayoffTrait; use Lc\CaracoleBundle\Doctrine\Extension\PayoffTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderPaymentInterface; use Lc\CaracoleBundle\Model\Order\OrderPaymentInterface;
use Lc\CaracoleBundle\Model\Order\OrderRefundInterface; use Lc\CaracoleBundle\Model\Order\OrderRefundInterface;
use Lc\CaracoleBundle\Doctrine\Extension\PayoffInterface; use Lc\CaracoleBundle\Doctrine\Extension\PayoffInterface;


/** /**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", inversedBy="creditHistories") * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", inversedBy="creditHistories")
* @ORM\JoinColumn(nullable=true, )
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/ */
protected $userMerchant; 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"}) * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderPaymentInterface", cascade={"persist"})
*/ */


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

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

return $this;
}


public function getOrderPayment(): ?OrderPaymentInterface public function getOrderPayment(): ?OrderPaymentInterface
{ {

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

protected $orderShops; 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; protected $orderRefund;



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



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



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

protected $productCategories; 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; protected $news;



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

protected $creditActive = false; 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; protected $creditHistories;



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

protected $userMerchants; 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; protected $reductionCredits;



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

$userMerchant = $this->getOneByUser($user, $query); $userMerchant = $this->getOneByUser($user, $query);
return $this->userMerchantSolver->isCreditActive($userMerchant); 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

boxes: boxes:
visitor: Visiteur visitor: Visiteur
user: Utilisateur user: Utilisateur

UserPointSale:
label_plurial: Liens avec une ambassade
PointSale: PointSale:
label: Point de vente label: Point de vente
label_plurial: Points de vente label_plurial: Points de vente
orderAmountMin: Montant minimum de commande orderAmountMin: Montant minimum de commande


Address: Address:
label_plurial: Adresses
fields: fields:
type: Type type: Type
typeOptions: typeOptions:
countOrder: Commandes countOrder: Commandes
totalSpent: Ventes totalSpent: Ventes
lastLogin: Dernière connexion 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: CreditHistory:
label: Historique de compte prépayé label: Historique de compte prépayé
label_plurial: Historiques de compte prépayé label_plurial: Historiques de compte prépayé

Loading…
Cancel
Save