|
|
@@ -41,7 +41,7 @@ class AdminController extends EasyAdminController |
|
|
|
protected $merchantUtils; |
|
|
|
protected $mailjetTransport; |
|
|
|
protected $orderUtils; |
|
|
|
protected $mailUtils ; |
|
|
|
protected $mailUtils; |
|
|
|
protected $translator; |
|
|
|
protected $utilsProcess; |
|
|
|
protected $sectionUtils; |
|
|
@@ -57,9 +57,9 @@ class AdminController extends EasyAdminController |
|
|
|
$this->utils = $utilsManager->getUtils(); |
|
|
|
$this->merchantUtils = $utilsManager->getMerchantUtils(); |
|
|
|
$this->orderUtils = $utilsManager->getOrderUtils();; |
|
|
|
$this->mailUtils = $utilsManager->getMailUtils() ; |
|
|
|
$this->utilsProcess = $utilsManager->getUtilsProcess() ; |
|
|
|
$this->sectionUtils = $utilsManager->getSectionUtils() ; |
|
|
|
$this->mailUtils = $utilsManager->getMailUtils(); |
|
|
|
$this->utilsProcess = $utilsManager->getUtilsProcess(); |
|
|
|
$this->sectionUtils = $utilsManager->getSectionUtils(); |
|
|
|
$this->translator = $translator; |
|
|
|
} |
|
|
|
|
|
|
@@ -133,9 +133,14 @@ class AdminController extends EasyAdminController |
|
|
|
$dqlFilter = sprintf(str_replace('currentMerchant', $this->getUser()->getMerchant()->getId(), $dqlFilter)); |
|
|
|
} |
|
|
|
|
|
|
|
if ($pos = strpos($dqlFilter, 'NOW()')) { |
|
|
|
$date = new \DateTime(); |
|
|
|
$dqlFilter = sprintf(str_replace('NOW()', $date->format('Y-m-d H:i:s'), $dqlFilter)); |
|
|
|
|
|
|
|
} |
|
|
|
if ($pos = strpos($dqlFilter, 'sectionLunch')) { |
|
|
|
$dqlFilter = sprintf(str_replace('sectionLunch', $this->sectionUtils->getSection('lunch')->getId(), $dqlFilter)); |
|
|
|
}else if ($pos = strpos($dqlFilter, 'sectionMarket')) { |
|
|
|
} else if ($pos = strpos($dqlFilter, 'sectionMarket')) { |
|
|
|
$dqlFilter = sprintf(str_replace('sectionMarket', $this->sectionUtils->getSection('market')->getId(), $dqlFilter)); |
|
|
|
} |
|
|
|
|
|
|
@@ -184,7 +189,7 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
if ($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) { |
|
|
|
foreach ($listFields as $field) { |
|
|
|
if ($this->filtersForm->has($field['property'])) { |
|
|
|
if ($this->filtersForm->has($field['property'])) { |
|
|
|
switch ($field['dataType']) { |
|
|
|
case 'option': |
|
|
|
case 'integer': |
|
|
@@ -207,9 +212,9 @@ class AdminController extends EasyAdminController |
|
|
|
} else { |
|
|
|
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); |
|
|
|
} |
|
|
|
if($filter instanceof TreeInterface && $filter->getParent() == null) { |
|
|
|
if ($filter instanceof TreeInterface && $filter->getParent() == null) { |
|
|
|
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$queryBuilder->setParameter($field['property'], $filter); |
|
|
|
} |
|
|
|
} |
|
|
@@ -536,7 +541,7 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
$id = $this->request->query->get('id'); |
|
|
|
$easyadmin = $this->request->attributes->get('easyadmin'); |
|
|
|
$entity = $easyadmin['item']; |
|
|
|
$entity = $easyadmin['item']; |
|
|
|
|
|
|
|
if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { |
|
|
|
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); |
|
|
@@ -581,65 +586,68 @@ class AdminController extends EasyAdminController |
|
|
|
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); |
|
|
|
} |
|
|
|
|
|
|
|
/* public function createNewEntity(){ |
|
|
|
$idDuplicate = $this->request->query->get('duplicate', null); |
|
|
|
if($idDuplicate){ |
|
|
|
$easyadmin = $this->request->attributes->get('easyadmin'); |
|
|
|
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($idDuplicate); |
|
|
|
/* public function createNewEntity(){ |
|
|
|
$idDuplicate = $this->request->query->get('duplicate', null); |
|
|
|
if($idDuplicate){ |
|
|
|
$easyadmin = $this->request->attributes->get('easyadmin'); |
|
|
|
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($idDuplicate); |
|
|
|
|
|
|
|
$newProductFamily = clone $entity ; |
|
|
|
$this->em->persist($newProductFamily) ; |
|
|
|
$this->em->flush() ; |
|
|
|
}else{ |
|
|
|
$entityFullyQualifiedClassName = $this->entity['class']; |
|
|
|
$newProductFamily = clone $entity ; |
|
|
|
$this->em->persist($newProductFamily) ; |
|
|
|
$this->em->flush() ; |
|
|
|
}else{ |
|
|
|
$entityFullyQualifiedClassName = $this->entity['class']; |
|
|
|
|
|
|
|
return new $entityFullyQualifiedClassName(); |
|
|
|
} |
|
|
|
return new $entityFullyQualifiedClassName(); |
|
|
|
} |
|
|
|
|
|
|
|
}*/ |
|
|
|
}*/ |
|
|
|
|
|
|
|
public function duplicateAction(){ |
|
|
|
public function duplicateAction() |
|
|
|
{ |
|
|
|
|
|
|
|
$id = $this->request->query->get('id'); |
|
|
|
$refererUrl = $this->request->query->get('referer', ''); |
|
|
|
|
|
|
|
$easyadmin = $this->request->attributes->get('easyadmin'); |
|
|
|
|
|
|
|
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id); |
|
|
|
$entity = $this->em->getRepository($easyadmin['entity']['class'])->find($id); |
|
|
|
|
|
|
|
$newEntity = $this->utilsProcess->duplicateEntity($entity); |
|
|
|
|
|
|
|
return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]) ; |
|
|
|
return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' => $newEntity->getId(), 'referer' => $refererUrl]); |
|
|
|
} |
|
|
|
|
|
|
|
public function duplicateOtherHubAction(){ |
|
|
|
public function duplicateOtherHubAction() |
|
|
|
{ |
|
|
|
|
|
|
|
$id = $this->request->query->get('id'); |
|
|
|
$hubAlias = $this->request->query->get('hub'); |
|
|
|
$refererUrl = $this->request->query->get('referer', ''); |
|
|
|
$user = $this->security->getUser() ; |
|
|
|
$user = $this->security->getUser(); |
|
|
|
|
|
|
|
$easyadmin = $this->request->attributes->get('easyadmin'); |
|
|
|
|
|
|
|
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id); |
|
|
|
$hub= $this->em->getRepository(MerchantInterface::class)->findOneByDevAlias($hubAlias); |
|
|
|
$entity = $this->em->getRepository($easyadmin['entity']['class'])->find($id); |
|
|
|
$hub = $this->em->getRepository(MerchantInterface::class)->findOneByDevAlias($hubAlias); |
|
|
|
|
|
|
|
$newEntity = $this->utilsProcess->duplicateEntityToOtherHub($entity,$hub); |
|
|
|
$newEntity = $this->utilsProcess->duplicateEntityToOtherHub($entity, $hub); |
|
|
|
|
|
|
|
$user->setMerchant($hub); |
|
|
|
$this->em->persist($user); |
|
|
|
$this->em->flush(); |
|
|
|
|
|
|
|
$redirectUrl = $this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]).'&hubredirection=true'; |
|
|
|
$redirectUrl = $this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' => $newEntity->getId(), 'referer' => $refererUrl]) . '&hubredirection=true'; |
|
|
|
|
|
|
|
return $this->redirectToOtherHub($hub, $redirectUrl) ; |
|
|
|
return $this->redirectToOtherHub($hub, $redirectUrl); |
|
|
|
} |
|
|
|
|
|
|
|
public function redirectToOtherHub($hub, $url){ |
|
|
|
if(strpos($_SERVER['HTTP_HOST'], 'localhost')!==false){ |
|
|
|
public function redirectToOtherHub($hub, $url) |
|
|
|
{ |
|
|
|
if (strpos($_SERVER['HTTP_HOST'], 'localhost') !== false) { |
|
|
|
return $this->redirect($url); |
|
|
|
}else{ |
|
|
|
return $this->redirect($hub->getMerchantConfig('url').substr($url,1)); |
|
|
|
} else { |
|
|
|
return $this->redirect($hub->getMerchantConfig('url') . substr($url, 1)); |
|
|
|
} |
|
|
|
|
|
|
|
} |