Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Fab 3 years ago
parent
commit
8fbf5b3c70
19 changed files with 349 additions and 63 deletions
  1. +1
    -1
      Model/Credit/CreditHistoryModel.php
  2. +46
    -0
      Repository/Credit/CreditHistoryRepositoryQuery.php
  3. +31
    -0
      Repository/Credit/CreditHistoryStore.php
  4. +12
    -0
      Repository/File/DocumentStore.php
  5. +2
    -0
      Repository/PointSale/PointSaleRepositoryQuery.php
  6. +3
    -0
      Repository/PointSale/PointSaleStore.php
  7. +2
    -0
      Repository/Product/ProductFamilyRepositoryQuery.php
  8. +3
    -0
      Repository/Product/ProductFamilyStore.php
  9. +34
    -5
      Repository/Reminder/ReminderStore.php
  10. +0
    -27
      Repository/Reminder/TicketStore.php
  11. +25
    -0
      Repository/Site/NewsStore.php
  12. +9
    -0
      Repository/Site/PageRepositoryQuery.php
  13. +59
    -0
      Repository/Site/PageStore.php
  14. +51
    -0
      Repository/Ticket/TicketStore.php
  15. +0
    -15
      Repository/User/GroupUserRepository.php
  16. +2
    -8
      Repository/User/GroupUserRepositoryQuery.php
  17. +2
    -7
      Repository/User/GroupUserStore.php
  18. +40
    -0
      Repository/User/UserRepositoryQuery.php
  19. +27
    -0
      Repository/User/UserStore.php

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

@@ -29,7 +29,7 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI
const MEAN_PAYMENT_CASH = 'cash';


/**
/**$merchant
* @ORM\Column(type="float", nullable=true)
*/
protected $amount;

+ 46
- 0
Repository/Credit/CreditHistoryRepositoryQuery.php View File

@@ -2,13 +2,59 @@

namespace Lc\CaracoleBundle\Repository\Credit;

use App\Entity\Merchant\Merchant;
use App\Entity\User\UserMerchant;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use DateTime;

class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
{
protected $isJoinUserMerchants = false;

public function __construct(CreditHistoryRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}

public function joinUserMerchant(): self
{
if (!$this->isJoinUserMerchants) {
$this->isJoinUserMerchants = true;

return $this
->innerJoin('.userMerchant', 'um');
}
return $this;
}

public function filterByJoinUserMerchant(Merchant $merchant): self
{
$this->joinUserMerchant();
return $this
->andWhere('um.merchant = :merchant')
->setParameter('merchant', $merchant);
}

public function filterByUserMerchant(UserMerchant $userMerchant): self
{
return $this
->andWhere('.userMerchant = :userMerchant')
->setParameter('userMerchant', $userMerchant);
}

public function filterByDateStart(DateTime $dateStart): self
{
return $this
->andWhere('.createdAt >= :dateStart')
->setParameter(':dateStart', $dateStart);
}

public function filterByDateEnd(DateTime $dateEnd): self
{
return $this
->andWhere('.createdAt <= :dateEnd')
->setParameter(':dateEnd', $dateEnd);
}
}

+ 31
- 0
Repository/Credit/CreditHistoryStore.php View File

@@ -2,14 +2,45 @@

namespace Lc\CaracoleBundle\Repository\Credit;

use App\Entity\User\UserMerchant;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use DateTime;

class CreditHistoryStore extends AbstractStore
{
use MerchantStoreTrait;

protected CreditHistoryRepositoryQuery $query;

public function __construct(CreditHistoryRepositoryQuery $query)
{
$this->query = $query;
}

//findAllByDateStartEnd
public function getByDateStartEnd(DateTime $dateStart, DateTime $dateEnd): array
{
$query = $this->query->create();

$query
->filterByJoinUserMerchant($this->merchant)
->filterByDateStart($dateStart)
->filterByDateEnd($dateEnd)
->orderBy('.createdAt');

return $query->find();
}

//findAllByUserMerchant
public function getByUserMerchant(UserMerchant $userMerchant): array
{
$query = $this->query->create();

$query
->filterByUserMerchant($userMerchant)
->orderBy('.createdAt', 'DESC');

return $query->find();
}
}

+ 12
- 0
Repository/File/DocumentStore.php View File

@@ -20,4 +20,16 @@ class DocumentStore extends AbstractStore
{
// @TODO : à écrire
}

//findLastInvoice
public function getOneLastInvoice()
{
$query = $this->query->create();

$query
->filterByMerchant($this->merchant)
->orderBy('.createdAt', 'DESC');

return $query->findOne();
}
}

+ 2
- 0
Repository/PointSale/PointSaleRepositoryQuery.php View File

@@ -5,10 +5,12 @@ namespace Lc\CaracoleBundle\Repository\PointSale;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class PointSaleRepositoryQuery extends AbstractRepositoryQuery
{
use StatusRepositoryQueryTrait;

public function __construct(PointSaleRepository $repository, PaginatorInterface $paginator)
{

+ 3
- 0
Repository/PointSale/PointSaleStore.php View File

@@ -2,10 +2,13 @@

namespace Lc\CaracoleBundle\Repository\PointSale;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;

class PointSaleStore extends AbstractStore
{
use MerchantStoreTrait;

protected PointSaleRepositoryQuery $query;

public function __construct(PointSaleRepositoryQuery $query)

+ 2
- 0
Repository/Product/ProductFamilyRepositoryQuery.php View File

@@ -5,11 +5,13 @@ namespace Lc\CaracoleBundle\Repository\Product;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
{
use SectionRepositoryQueryTrait;
use StatusRepositoryQueryTrait;

public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator)
{

+ 3
- 0
Repository/Product/ProductFamilyStore.php View File

@@ -4,11 +4,14 @@ namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
use Lc\SovBundle\Repository\AbstractStore;

class ProductFamilyStore extends AbstractStore
{
use SectionStoreTrait;

protected ProductFamilyRepositoryQuery $query;
protected PriceResolver $priceResolver;


+ 34
- 5
Repository/Reminder/ReminderStore.php View File

@@ -2,10 +2,9 @@

namespace Lc\CaracoleBundle\Repository\Reminder;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore;

class ReminderStore extends SovReminderStore
@@ -15,19 +14,49 @@ class ReminderStore extends SovReminderStore

public function get($params = [], $query = null)
{
if(is_null($query)) {
if (is_null($query)) {
$query = $this->query->create();
}

if($this->merchant) {
if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

if($this->section) {
if ($this->section) {
$query->filterBySection($this->section);
}

return parent::get($params, $query);
}

public function getByUser(UserInterface $user, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getByUser($user, $query);
}

public function getByEasyAdminConfigAndUser(
string $crudAction,
string $crudControllerFqcn,
UserInterface $user,
int $entityId = null,
$query = null
): array {
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId, $query);
}
}

+ 0
- 27
Repository/Reminder/TicketStore.php View File

@@ -1,27 +0,0 @@
<?php

namespace Lc\CaracoleBundle\Repository\Reminder;

use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

class TicketStore extends SovReminderStore
{
protected MerchantInterface $merchant;

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

public function getFoo($query = null)
{
$query = $this->query->create();

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getFoo($query);
}
}

+ 25
- 0
Repository/Site/NewsStore.php View File

@@ -0,0 +1,25 @@
<?php

namespace Lc\CaracoleBundle\Repository\Site;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\Site\NewsStore as SovNewsStore;

class NewsStore extends SovNewsStore
{
use MerchantStoreTrait;

public function getLatests(int $maxResults = 0, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getLatests($maxResults, $query);
}

}

+ 9
- 0
Repository/Site/PageRepositoryQuery.php View File

@@ -4,10 +4,19 @@ namespace Lc\CaracoleBundle\Repository\Site;

use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery;

class PageRepositoryQuery extends SovPageRepositoryQuery
{
use SectionRepositoryQueryTrait;
use StatusRepositoryQueryTrait;

public function filterByDevAlias(string $devAlias): self
{
return $this
->andWhere('.devAlias = :devAlias')
->setParameter('devAlias', $devAlias);
}

}

+ 59
- 0
Repository/Site/PageStore.php View File

@@ -0,0 +1,59 @@
<?php

namespace Lc\CaracoleBundle\Repository\Site;

use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\Site\PageInterface;
use Lc\SovBundle\Repository\Site\PageStore as SovPageStore;

class PageStore extends SovPageStore
{
use SectionStoreTrait;

public function __construct(PageRepositoryQuery $query)
{
parent::__construct($query);
}

// TODO Vérifier si c'est good avec la section
// findPage
public function getOnePage(string $devAlias, SectionInterface $section = null): ?PageInterface
{
$query = $this->query->create();

if ($section == null) {
$section = $this->section;
}
$query
->filterIsOnline()
->filterByDevAlias($devAlias)
->filterBySection($section);

return $query->findOne();
}

// public function findPage($devAlias, $devAliasMerchant = false)
// {
// $merchant = false;
//
// if ($devAliasMerchant) {
// $merchant = $this->merchantUtils->getMerchantByDevAlias($devAliasMerchant);
// }
//
// if ($devAliasMerchant && $merchant) {
// $query = $this->createQueryBuilder('e')
// ->where('e.merchant = :merchant')
// ->setParameter('merchant', $merchant->getId());
// } else {
// $query = $this->findByMerchantQuery();
// }
//
// return $query->andWhere('e.status = 1')
// ->andWhere('e.devAlias = :devAlias')
// ->setParameter('devAlias', $devAlias)
// ->getQuery()
// ->getOneOrNullResult();
// }

}

+ 51
- 0
Repository/Ticket/TicketStore.php View File

@@ -0,0 +1,51 @@
<?php

namespace Lc\CaracoleBundle\Repository\Ticket;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\Ticket\TicketStore as SovTicketStore;

class TicketStore extends SovTicketStore
{
use MerchantStoreTrait;

public function getByUser($user, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getByUser($user, $query);
}

public function getAllOpen(int $limit = 0, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getAllOpen($limit, $query);
}

public function countAllOpen($query = null): string
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::countAllOpen($query);
}

}

+ 0
- 15
Repository/User/GroupUserRepository.php View File

@@ -1,15 +0,0 @@
<?php

namespace Lc\CaracoleBundle\Repository\User;

use App\Entity\User\GroupUser;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository;

class GroupUserRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, GroupUser::class);
}
}

+ 2
- 8
Repository/User/GroupUserRepositoryQuery.php View File

@@ -2,16 +2,10 @@

namespace Lc\CaracoleBundle\Repository\User;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use Lc\SovBundle\Repository\User\GroupUserRepositoryQuery as SovAbstractRepositoryQuery;

class GroupUserRepositoryQuery extends AbstractRepositoryQuery
class GroupUserRepositoryQuery extends SovAbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;

public function __construct(GroupUserRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}
}

+ 2
- 7
Repository/User/GroupUserStore.php View File

@@ -2,14 +2,9 @@

namespace Lc\CaracoleBundle\Repository\User;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\User\GroupUserStore as SovGroupUserStore;

class GroupUserStore extends AbstractStore
class GroupUserStore extends SovGroupUserStore
{
protected GroupUserRepositoryQuery $query;

public function __construct(GroupUserRepositoryQuery $query)
{
$this->query = $query;
}
}

+ 40
- 0
Repository/User/UserRepositoryQuery.php View File

@@ -0,0 +1,40 @@
<?php

namespace Lc\CaracoleBundle\Repository\User;

use App\Entity\Merchant\Merchant;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\SovBundle\Repository\User\UserRepositoryQuery as SovUserRepositoryQuery;

class UserRepositoryQuery extends SovUserRepositoryQuery
{
use MerchantRepositoryQueryTrait;

protected $isJoinUserMerchants = false;

public function joinUserMerchants(): self
{
if (!$this->isJoinUserMerchants) {
$this->isJoinUserMerchants = true;

return $this
->innerJoin('.userMerchants', 'um');
}
return $this;
}

public function filterMerchantIsActive(): self
{
$this->joinUserMerchants();
return $this
->andWhere('um.active = 1');
}

public function filterByJoinUserMerchant(Merchant $merchant): self
{
$this->joinUserMerchants();
return $this
->andWhere('um.merchant = :merchant')
->setParameter('merchant', $merchant);
}
}

+ 27
- 0
Repository/User/UserStore.php View File

@@ -0,0 +1,27 @@
<?php

namespace Lc\CaracoleBundle\Repository\User;

use App\Entity\Newsletter\Newsletter;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\User\UserStore as SovUserStore;

class UserStore extends SovUserStore
{
use MerchantStoreTrait;

public function getByNewsletter(Newsletter $newsletter, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query
->filterByJoinUserMerchant($this->merchant)
->filterMerchantIsActive();
}

return parent::getByNewsletter($newsletter, $query);
}
}

Loading…
Cancel
Save