Browse Source

Intégration app order

packProduct
Fab 3 years ago
parent
commit
cf3c41ffb4
8 changed files with 56 additions and 37 deletions
  1. +14
    -15
      Controller/AdminControllerTrait.php
  2. +2
    -2
      Controller/Setting/SettingAdminController.php
  3. +4
    -7
      Controller/User/UserMerchantAdminController.php
  4. +5
    -1
      Factory/Order/OrderProductFactory.php
  5. +26
    -9
      Field/AssociationField.php
  6. +1
    -1
      Repository/Product/ProductRepositoryQuery.php
  7. +1
    -0
      Repository/Product/ProductStore.php
  8. +3
    -2
      Solver/Price/OrderProductPriceSolver.php

+ 14
- 15
Controller/AdminControllerTrait.php View File

parent::getSubscribedServices(), parent::getSubscribedServices(),
[ [
MerchantResolver::class => MerchantResolver::class, MerchantResolver::class => MerchantResolver::class,
SectionResolver::class=> SectionResolver::class,
SectionResolver::class => SectionResolver::class,
AddressContainer::class => AddressContainer::class, AddressContainer::class => AddressContainer::class,
TaxRateContainer::class => TaxRateContainer::class, TaxRateContainer::class => TaxRateContainer::class,
UnitContainer::class => UnitContainer::class, UnitContainer::class => UnitContainer::class,
->setAction(Action::EDIT) ->setAction(Action::EDIT)
->setEntityId($newEntity->getId()) ->setEntityId($newEntity->getId())
->generateUrl(); ->generateUrl();
$this->addFlash(
$this->addFlashTranslator(
'success', 'success',
$translatorAdmin->transFlashMessage(
'duplicateToOtherMerchant',
['%merchant%' => $merchant->getTitle()]
),
array()
'duplicateToOtherMerchant',
$this->getTranslationEntityName(),
['%merchant%' => $merchant->getTitle()]
); );


//TODO switch merchant route //TODO switch merchant route
->setAction(Action::EDIT) ->setAction(Action::EDIT)
->setEntityId($newEntity->getId()) ->setEntityId($newEntity->getId())
->generateUrl(); ->generateUrl();
$this->addFlash(
$this->addFlashTranslator(
'success', 'success',
$translatorAdmin->transFlashMessage(
'duplicateToOtherSection',
['%section%' => $section->getTitle()]
),
array()
'duplicateToOtherSection',
$this->getTranslationEntityName(),
['%section%' => $section->getTitle()]
); );


//TODO switch merchant route //TODO switch merchant route
return $duplicateAction; return $duplicateAction;
} }


public function getCurrentSection(){
public function getCurrentSection()
{
return $this->get(SectionResolver::class)->getCurrent(); return $this->get(SectionResolver::class)->getCurrent();
} }
public function getCurrentMerchant(){

public function getCurrentMerchant()
{
return $this->get(MerchantResolver::class)->getCurrent(); return $this->get(MerchantResolver::class)->getCurrent();
} }
} }

+ 2
- 2
Controller/Setting/SettingAdminController.php View File

$entityManager->update($entity); $entityManager->update($entity);
$entityManager->flush(); $entityManager->flush();


$this->addFlash('success', $this->getTranslatorAdmin()->transFlashMessage('settings_saved'));
$this->addFlashTranslator('success','updated');
} }


return $this->render( return $this->render(
$entityManager->update($site); $entityManager->update($site);
$entityManager->flush(); $entityManager->flush();


$this->addFlash('success', $this->getTranslatorAdmin()->transFlashMessage('settings_saved'));
$this->addFlashTranslator('success','updated');
} }


return $this->render( return $this->render(

+ 4
- 7
Controller/User/UserMerchantAdminController.php View File

$userMerchant->setUser($user); $userMerchant->setUser($user);
$entityManager->create($userMerchant); $entityManager->create($userMerchant);
$entityManager->flush(); $entityManager->flush();
$this->addFlash('success', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.create'));
$this->addFlashTranslator('success','created');
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); $url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl();


return $this->redirect($url); return $this->redirect($url);
$entityManager->create($userMerchant); $entityManager->create($userMerchant);
$entityManager->flush(); $entityManager->flush();


$this->addFlash('success', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.linked'));
$this->addFlashTranslator('success', 'linked');
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); $url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl();


return $this->redirect($url); return $this->redirect($url);
} else { } else {
$this->addFlash(
'error',
$this->get(TranslatorAdmin::class)->trans('form.user_merchant.already_exist')
);
$this->addFlashTranslator('error','already_exist');
} }
} }
} }
$entityManager->update($userMerchant); $entityManager->update($userMerchant);
$entityManager->update($userMerchant->getUser()); $entityManager->update($userMerchant->getUser());
$entityManager->flush(); $entityManager->flush();
$this->addFlash('success', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.update'));
$this->addFlashTranslator('success', 'updated');
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); $url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl();


return $this->redirect($url); return $this->redirect($url);

+ 5
- 1
Factory/Order/OrderProductFactory.php View File

{ {
public function create(ProductInterface $product, int $quantityOrder): OrderProductInterface public function create(ProductInterface $product, int $quantityOrder): OrderProductInterface
{ {
$orderProduct = new OrderProduct();
$orderProduct = $this->createBase();


$orderProduct->setProduct($product); $orderProduct->setProduct($product);
$orderProduct->setQuantityOrder($quantityOrder); $orderProduct->setQuantityOrder($quantityOrder);
return $orderProduct; return $orderProduct;
} }


public function createBase(){
return new OrderProduct();
}

} }

+ 26
- 9
Field/AssociationField.php View File

return $this; return $this;
} }


public function setLeftJoin($entityName): self{
public function setLeftJoin($entityName): self
{
$this->queryBuilderParameters['leftJoin'][] = $entityName; $this->queryBuilderParameters['leftJoin'][] = $entityName;


return $this; return $this;
} }


public function addAndWhere($whereClause, $parameter): self
{
$this->queryBuilderParameters['leftJoin'][] = [
'whereClause' => $whereClause,
'parameter' => $parameter
];

return $this;
}


public function addOrderBy($field, $direction ='ASC') : self

public function addOrderBy($field, $direction = 'ASC'): self
{ {
$this->queryBuilderParameters['orderBy'][] = $field; $this->queryBuilderParameters['orderBy'][] = $field;
$this->queryBuilderParameters['orderByDirection'][] = $direction; $this->queryBuilderParameters['orderByDirection'][] = $direction;
function (EntityRepository $er) use ($param) { function (EntityRepository $er) use ($param) {
$qb = $er->createQueryBuilder('e'); $qb = $er->createQueryBuilder('e');
if (isset($param['section'])) { if (isset($param['section'])) {
$qb->andWhereSection('e',$param['section']);
$qb->andWhereSection('e', $param['section']);
} }
if (isset($param['merchant'])) { if (isset($param['merchant'])) {
$qb->andWhereMerchant('e',$param['merchant']);
$qb->andWhereMerchant('e', $param['merchant']);
} }


if (isset($param['merchantManyToMany'])) { if (isset($param['merchantManyToMany'])) {
$qb->andWhereMerchantManyToMany('e',$param['merchantManyToMany']);
$qb->andWhereMerchantManyToMany('e', $param['merchantManyToMany']);
} }


if (isset($param['status'])) { if (isset($param['status'])) {
} }


if (isset($param['orderBy'])) { if (isset($param['orderBy'])) {
foreach ($param['orderBy'] as $i=>$field) {
$qb->addOrderBy('e.'.$param['orderBy'][$i], $param['orderByDirection'][$i]);
foreach ($param['orderBy'] as $i => $field) {
$qb->addOrderBy('e.' . $param['orderBy'][$i], $param['orderByDirection'][$i]);
} }
} }


if (isset($param['leftJoin'])) { if (isset($param['leftJoin'])) {
foreach ($param['leftJoin'] as $i=>$entityName) {
$qb->leftJoin('e.'.$entityName, $entityName)->addSelect($entityName);
foreach ($param['leftJoin'] as $i => $entityName) {
$qb->leftJoin('e.' . $entityName, $entityName)->addSelect($entityName);
}
}

if (isset($param['andWhere'])) {
foreach ($param['andWhere'] as $i => $whereClause) {
$qb->andWhere($whereClause['whereClause'])->setParamater($whereClause['parameter']);
} }
} }



+ 1
- 1
Repository/Product/ProductRepositoryQuery.php View File



class ProductRepositoryQuery extends AbstractRepositoryQuery class ProductRepositoryQuery extends AbstractRepositoryQuery
{ {
protected bool $isJoinProductFamily;
protected bool $isJoinProductFamily =false;


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

+ 1
- 0
Repository/Product/ProductStore.php View File

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


public function relationsDefault($query):RepositoryQueryInterface public function relationsDefault($query):RepositoryQueryInterface

+ 3
- 2
Solver/Price/OrderProductPriceSolver.php View File



public function getTotalWithTax(OrderProductInterface $orderProduct) public function getTotalWithTax(OrderProductInterface $orderProduct)
{ {

return $this->applyTax( return $this->applyTax(
$this->getTotal($orderProduct), $this->getTotal($orderProduct),
$orderProduct->getTaxRateInherited()->getValue()
$orderProduct->getTaxRate()->getValue()
); );
} }


{ {
return $this->applyTax( return $this->applyTax(
$this->getTotalBuyingPrice($orderProduct), $this->getTotalBuyingPrice($orderProduct),
$orderProduct->getTaxRateInherited()->getValue()
$orderProduct->getTaxRate()->getValue()
); );
} }



Loading…
Cancel
Save