<?php | |||||
namespace Lc\SovBundle\Builder\Ticket; | |||||
use Lc\SovBundle\Component\FormComponent; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
class TicketBuilder | |||||
{ | |||||
protected FormComponent $formComponent; | |||||
protected ParameterBagInterface $parameterBag; | |||||
public function __construct(FormComponent $formComponent, ParameterBagInterface $parameterBag) | |||||
{ | |||||
$this->formComponent = $formComponent; | |||||
$this->parameterBag = $parameterBag; | |||||
} | |||||
// uploadImageTicketMessage | |||||
public function uploadImageTicketMessage($formTicket) | |||||
{ | |||||
return $this->formComponent->uploadFile( | |||||
$formTicket, | |||||
'image', | |||||
$this->parameterBag->get('app.ticket_images_directory'), | |||||
$this->parameterBag->get('app.ticket_images_subdirectory') | |||||
); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Builder\User; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
class UserBuilder | |||||
{ | |||||
protected EntityManagerInterface $entityManager; | |||||
public function __construct(EntityManagerInterface $entityManager) | |||||
{ | |||||
$this->entityManager = $entityManager; | |||||
} | |||||
public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter) | |||||
{ | |||||
if ($subscribeNewsletter) { | |||||
$user->addNewsletter($newsletter); | |||||
} else { | |||||
$user->removeNewsletter($newsletter); | |||||
} | |||||
$this->entityManager->persist($user); | |||||
$this->entityManager->flush(); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Component; | |||||
use Lc\SovBundle\Resolver\UrlResolver; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
class CookieComponent | |||||
{ | |||||
protected UrlResolver $urlResolver; | |||||
protected ParameterBagInterface $parameterBag; | |||||
public function __construct(UrlResolver $urlResolver, ParameterBagInterface $parameterBag) | |||||
{ | |||||
$this->urlResolver = $urlResolver; | |||||
$this->parameterBag = $parameterBag; | |||||
} | |||||
public function getCookieDomain() | |||||
{ | |||||
return ($this->urlResolver->isServerLocalhost()) ? null : $this->parameterBag->get('app.cookie_domain_distant'); | |||||
} | |||||
public function cryptCookie($data) | |||||
{ | |||||
return base64_encode($data); | |||||
} | |||||
public function decryptCookie($data) | |||||
{ | |||||
return base64_decode($data); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Component; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\SluggableInterface; | |||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
class EntityComponent | |||||
{ | |||||
protected EntityManagerInterface $entityManager; | |||||
protected ParameterBagInterface $parameterBag; | |||||
public function __construct( | |||||
EntityManagerInterface $entityManager, | |||||
ParameterBagInterface $parameterBag | |||||
) { | |||||
$this->entityManager = $entityManager; | |||||
$this->parameterBag = $parameterBag; | |||||
} | |||||
public function duplicateEntity($entity, $flush = true) | |||||
{ | |||||
$newEntity = clone $entity; | |||||
if ($newEntity instanceof FileInterface) { | |||||
$newEntity = $this->duplicateImage($newEntity); | |||||
} | |||||
if ($newEntity instanceof ProductFamilyInterface) { | |||||
// @TODO : à adapter | |||||
//$newEntity = $this->productFamilyUtils->processBeforePersistProductFamily($newEntity, false, true); | |||||
} | |||||
if (method_exists($newEntity, 'getAddress') && is_object($newEntity->getAddress())) { | |||||
$address = $newEntity->getAddress(); | |||||
$newAddress = $this->duplicateEntity($address); | |||||
$newEntity->setAddress($newAddress); | |||||
$this->entityManager->persist($newAddress); | |||||
} | |||||
if ($newEntity instanceof SluggableInterface) { | |||||
$this->entityManager->persist($newEntity); | |||||
if ($flush) { | |||||
$this->entityManager->flush(); | |||||
} | |||||
$newEntity->setSlug(null); | |||||
} | |||||
$this->entityManager->persist($newEntity); | |||||
if ($flush) { | |||||
$this->entityManager->flush(); | |||||
} | |||||
return $newEntity; | |||||
} | |||||
public function duplicateEntityToOtherHub($entity, $hub) | |||||
{ | |||||
$newEntity = $this->duplicateEntity($entity); | |||||
if ($hub) { | |||||
$newEntity->setMerchant($hub); | |||||
} | |||||
$this->entityManager->persist($newEntity); | |||||
$this->entityManager->flush(); | |||||
return $newEntity; | |||||
} | |||||
public function duplicateImage($entity, $folder = false) | |||||
{ | |||||
$basePath = $this->parameterBag->get('kernel.project_dir') . '/public/uploads/images/'; | |||||
if ($entity->getImage() && file_exists($basePath . $entity->getImage())) { | |||||
$extension = strtolower(pathinfo($basePath . $entity->getImage(), PATHINFO_EXTENSION)); | |||||
if ($extension == "jpg" || $extension == "png" || $extension == "gif") { | |||||
$newImage = md5(uniqid()) . '.' . $extension; | |||||
if ($folder) { | |||||
$newImage = $folder . '/' . $newImage; | |||||
} | |||||
copy($basePath . $entity->getImage(), $basePath . $newImage); | |||||
$entity->setImage($newImage); | |||||
} else { | |||||
$entity->setImage(null); | |||||
} | |||||
} else { | |||||
$entity->setImage(null); | |||||
} | |||||
return $entity; | |||||
} | |||||
} |
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | use Symfony\Component\Form\Extension\Core\Type\HiddenType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\HttpFoundation\File\Exception\FileException; | |||||
class FormComponent | class FormComponent | ||||
{ | { | ||||
]); | ]); | ||||
} | } | ||||
// uploadImageTicketMessage | |||||
public function uploadFile($form, $child, $directory, $subdirectory) | |||||
{ | |||||
$file = $form->get($child)->getData(); | |||||
if ($file) { | |||||
$originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME); | |||||
$newFilename = uniqid().'.'.$file->guessExtension(); | |||||
try { | |||||
$file->move( | |||||
$directory, | |||||
$newFilename | |||||
); | |||||
} catch (FileException $e) { | |||||
throw new \ErrorException("Une erreur est survenue lors de l'upload du fichier."); | |||||
} | |||||
return $subdirectory.$newFilename; | |||||
} | |||||
return false; | |||||
} | |||||
} | } |
if ($this->isInstanceOf(TreeInterface::class)) { | if ($this->isInstanceOf(TreeInterface::class)) { | ||||
$entityId = $searchDto->getRequest()->get('entityId'); | $entityId = $searchDto->getRequest()->get('entityId'); | ||||
if ($entityId !== null) { | if ($entityId !== null) { | ||||
$queryBuilder->andWhere('entity.parent = :entityId'); | |||||
$queryBuilder->setParameter('entityId', $searchDto->getRequest()->get('entityId')); | |||||
$queryBuilder->andWhereParent('entity', $entityId); | |||||
} else { | } else { | ||||
$queryBuilder->andWhere('entity.parent IS NULL'); | |||||
$queryBuilder->andWhereParentIsNull('entity'); | |||||
} | } | ||||
} | } | ||||
use Doctrine\ORM\EntityManager as DoctrineEntityManager; | use Doctrine\ORM\EntityManager as DoctrineEntityManager; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\SovBundle\Event\EntityManager\EntityManagerEvent; | use Lc\SovBundle\Event\EntityManager\EntityManagerEvent; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||||
/** | /** | ||||
parent::__construct($wrapped); | parent::__construct($wrapped); | ||||
} | } | ||||
public function createQueryBuilder() | |||||
{ | |||||
return new QueryBuilder($this); | |||||
} | |||||
public function getRepository($className) | public function getRepository($className) | ||||
{ | { | ||||
return $this->wrapped->getRepository($this->getEntityName($className)); | return $this->wrapped->getRepository($this->getEntityName($className)); |
<?php | |||||
namespace Lc\SovBundle\Doctrine; | |||||
use Doctrine\ORM\QueryBuilder as DoctrineQueryBuilder; | |||||
/** | |||||
* class QueryBuilder. | |||||
* | |||||
* @author La clic !!!! | |||||
*/ | |||||
class QueryBuilder extends DoctrineQueryBuilder | |||||
{ | |||||
public function andWhereParent($dqlId, $entityId):self | |||||
{ | |||||
$this->andWhere($dqlId.'.parent = :entityId'); | |||||
$this->setParameter('entityId', $entityId); | |||||
return $this; | |||||
} | |||||
public function andWhereParentIsNull($dqlId):self | |||||
{ | |||||
$this->andWhere($dqlId.'.parent IS NULL'); | |||||
return $this; | |||||
} | |||||
/*public function andIsOnline(){ | |||||
}*/ | |||||
} |
use App\Entity\Ticket\Ticket; | use App\Entity\Ticket\Ticket; | ||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | use Lc\SovBundle\Model\Ticket\TicketInterface; | ||||
use Lc\SovBundle\Model\Ticket\TicketModel; | |||||
class TicketFactory extends AbstractFactory implements TicketFactoryInterface | class TicketFactory extends AbstractFactory implements TicketFactoryInterface | ||||
{ | { | ||||
public function create(): TicketInterface | public function create(): TicketInterface | ||||
{ | { | ||||
$ticket = new Ticket(); | $ticket = new Ticket(); | ||||
$ticketMessageFactory = new TicketMessageFactory(); | $ticketMessageFactory = new TicketMessageFactory(); | ||||
$ticketMessage = $ticketMessageFactory->create() ; | |||||
$ticketMessage = $ticketMessageFactory->create($ticket) ; | |||||
$ticket->setStatus(TicketModel::TICKET_STATUS_OPEN); | |||||
$ticket->addTicketMessage($ticketMessage) ; | $ticket->addTicketMessage($ticketMessage) ; | ||||
return $ticket; | return $ticket; | ||||
} | } | ||||
} | } |
use App\Entity\Ticket\TicketMessage; | use App\Entity\Ticket\TicketMessage; | ||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||||
use Lc\SovBundle\Model\Ticket\TicketMessageInterface; | use Lc\SovBundle\Model\Ticket\TicketMessageInterface; | ||||
class TicketMessageFactory extends AbstractFactory implements TicketMessageFactoryInterface | class TicketMessageFactory extends AbstractFactory implements TicketMessageFactoryInterface | ||||
{ | { | ||||
public function create(): TicketMessageInterface | |||||
public function create(TicketInterface $ticket): TicketMessageInterface | |||||
{ | { | ||||
$ticketMessage = new TicketMessage(); | $ticketMessage = new TicketMessage(); | ||||
$ticketMessage->setTicket($ticket); | |||||
$ticketMessage->setStatus(1); | $ticketMessage->setStatus(1); | ||||
return $ticketMessage; | return $ticketMessage; |
DoctrineOrmTypeGuesser $doctrineOrmTypeGuesser, | DoctrineOrmTypeGuesser $doctrineOrmTypeGuesser, | ||||
\EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType $crudFormType | \EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType $crudFormType | ||||
) { | ) { | ||||
$this->parent = $crudFormType; | $this->parent = $crudFormType; | ||||
$this->doctrineOrmTypeGuesser = $doctrineOrmTypeGuesser; | $this->doctrineOrmTypeGuesser = $doctrineOrmTypeGuesser; | ||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$this->parent->buildForm($builder, $options); | $this->parent->buildForm($builder, $options); | ||||
$entityDto = $options['entityDto']; | $entityDto = $options['entityDto']; | ||||
$formPanels = []; | $formPanels = []; | ||||
$currentFormPanel = 0; | $currentFormPanel = 0; | ||||
foreach ($entityDto->getFields() as $fieldDto) { | foreach ($entityDto->getFields() as $fieldDto) { | ||||
if (null === $formFieldType = $fieldDto->getFormType()) { | if (null === $formFieldType = $fieldDto->getFormType()) { | ||||
$guessType = $this->doctrineOrmTypeGuesser->guessType($entityDto->getFqcn(), $fieldDto->getProperty()); | $guessType = $this->doctrineOrmTypeGuesser->guessType($entityDto->getFqcn(), $fieldDto->getProperty()); | ||||
$formFieldType = $guessType->getType(); | $formFieldType = $guessType->getType(); |
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||||
use Symfony\Component\Security\Core\User\UserInterface; | use Symfony\Component\Security\Core\User\UserInterface; | ||||
/** | /** | ||||
*/ | */ | ||||
protected $groupUsers; | protected $groupUsers; | ||||
// isUserInGroupVip | |||||
public function isInGroupUserVip() | |||||
{ | |||||
return $this->isInGroupByDevAlias('vip') ; | |||||
} | |||||
// isUserInGroup | |||||
public function isInGroupUser(GroupUserInterface $groupUser) | |||||
{ | |||||
return $this->isInGroupByDevAlias($groupUser->getDevAlias()); | |||||
} | |||||
// isUserInGroupByDevAlias | |||||
public function isInGroupByDevAlias(string $groupUserDevAlias) | |||||
{ | |||||
$groupUsers = $this->getGroupUsers(); | |||||
foreach($groupUsers as $groupUser) { | |||||
if($groupUser->getDevAlias() == $groupUserDevAlias) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
public function isSubscribedToNewsletter(NewsletterInterface $newsletter) | |||||
{ | |||||
return $this->getNewsletters()->contains($newsletter); | |||||
} | |||||
public function getEmail(): ?string | public function getEmail(): ?string | ||||
{ | { | ||||
return $this->email; | return $this->email; |
namespace Lc\SovBundle\Repository\Ticket; | namespace Lc\SovBundle\Repository\Ticket; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class TicketRepositoryQuery extends AbstractRepositoryQuery implements TicketRepositoryQueryInterface | class TicketRepositoryQuery extends AbstractRepositoryQuery implements TicketRepositoryQueryInterface | ||||
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterByUser(UserInterface $user) | |||||
{ | |||||
return $this | |||||
->andWhere('.user = :user') | |||||
->setParameter('user', $user); | |||||
} | |||||
} | } |
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
// getTicketsByUser | |||||
public function getByUser($user) | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->filterByUser($user); | |||||
return $query->find(); | |||||
} | |||||
} | } |
namespace Lc\SovBundle\Repository\User; | namespace Lc\SovBundle\Repository\User; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
class UserStore extends AbstractStore implements UserStoreInterface | class UserStore extends AbstractStore implements UserStoreInterface |
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']); | return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']); | ||||
} | } | ||||
public function getCookieDomain() | |||||
{ | |||||
return ($this->isServerLocalhost()) ? null : $this->parameterBag->get('app.cookie_domain_distant'); | |||||
} | |||||
public function isBot() | public function isBot() | ||||
{ | { | ||||
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match( | if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match( |
import { SovTools } from '../../../functions/tools.js'; | import { SovTools } from '../../../functions/tools.js'; | ||||
global.SovTools = SovTools; | global.SovTools = SovTools; | ||||
// Prices | |||||
import { SovPrices } from '../../../functions/prices.js'; | |||||
global.SovPrices = SovPrices; | |||||
// Widgets | // Widgets | ||||
import { SovWidgets } from '../../../functions/widgets.js'; | import { SovWidgets } from '../../../functions/widgets.js'; | ||||
global.SovWidgets = SovWidgets; | global.SovWidgets = SovWidgets; |
export class SovPrices { | |||||
static getPrice(priceWithTax, taxRate) { | |||||
return parseFloat(parseFloat(priceWithTax) / ((taxRate/100) + 1)).toFixed(4); | |||||
} | |||||
static getPriceWithTax(priceWithoutTax, taxRate) { | |||||
return parseFloat(parseFloat(priceWithoutTax) * ((taxRate/100) + 1)).toFixed(2); | |||||
} | |||||
static getMargin(price, buyingPrice){ | |||||
return parseFloat(price - buyingPrice).toFixed(2); | |||||
} | |||||
static getMarginPercent(price, buyingPrice){ | |||||
return parseFloat(((price - buyingPrice) / price) * 100).toFixed(2); | |||||
} | |||||
static applyReductionPercent(price, percentage) | |||||
{ | |||||
return applyPercent(price, -percentage); | |||||
} | |||||
static applyReductionAmount(price, amount) | |||||
{ | |||||
return parseFloat(price - amount).toFixed(2); | |||||
} | |||||
static applyPercent(price, percentage) | |||||
{ | |||||
return parseFloat(price * (percentage / 100 + 1)).toFixed(2); | |||||
} | |||||
} |
for (; input[i] < '0' || input[i] > '9'; i--) ; | for (; input[i] < '0' || input[i] > '9'; i--) ; | ||||
return i == input.length ? -1 : i; | return i == input.length ? -1 : i; | ||||
} | } | ||||
static formatNumber(number, toFixed){ | |||||
if(number)return Number(number.replace(',', '.')).toFixed(toFixed); | |||||
else return null; | |||||
} | |||||
static formatNumberWithoutFixed(number){ | |||||
if(typeof number == 'string')number = number.replace(',', '.'); | |||||
if(number)return Number(number); | |||||
else return null; | |||||
} | |||||
static getUrlParameter(sParam) { | |||||
var sPageURL = window.location.search.substring(1), | |||||
sURLVariables = sPageURL.split('&'), | |||||
sParameterName, | |||||
i; | |||||
for (i = 0; i < sURLVariables.length; i++) { | |||||
sParameterName = sURLVariables[i].split('='); | |||||
if (sParameterName[0] === sParam) { | |||||
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); | |||||
} | |||||
} | |||||
}; | |||||
} | } |
exclude: | exclude: | ||||
- '../../DependencyInjection/' | - '../../DependencyInjection/' | ||||
- '../../Entity/' | - '../../Entity/' | ||||
- '../../Doctrine/QueryBuilder' | |||||
- '../../Kernel.php' | - '../../Kernel.php' | ||||
- '../../Tests/' | - '../../Tests/' | ||||
{%- else -%} | {%- else -%} | ||||
{% set form_method = "POST" %} | {% set form_method = "POST" %} | ||||
{%- endif -%} | {%- endif -%} | ||||
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}> | |||||
<form{% if name != '' %} name="{{ name }}"{% endif %} | |||||
method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}> | |||||
{%- if form_method != method -%} | {%- if form_method != method -%} | ||||
<input type="hidden" name="_method" value="{{ method }}" /> | |||||
<input type="hidden" name="_method" value="{{ method }}"/> | |||||
{%- endif -%} | {%- endif -%} | ||||
<input type="hidden" name="referrer" value="{% if ea is defined %}{{ ea.request.query.get('referrer') }}{% endif %}"> | |||||
{% endblock form_start %} | |||||
<input type="hidden" name="referrer" | |||||
value="{% if ea is defined %}{{ ea.request.query.get('referrer') }}{% endif %}"> | |||||
{% endblock form_start %} | |||||
{% block form_row %} | |||||
{% set row_attr = row_attr|merge({ | |||||
class: row_attr.class|default('') ~ ' form-group' | |||||
}) %} | |||||
{% block form_row %} | |||||
{% set row_attr = row_attr|merge({ | |||||
class: row_attr.class|default('') ~ ' form-group' | |||||
}) %} | |||||
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}> | |||||
{{- form_label(form) -}} | |||||
<div class="form-widget"> | |||||
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}> | |||||
{{- form_label(form) -}} | |||||
<div class="form-widget"> | |||||
{# | |||||
{# | |||||
{% set has_prepend_html = ea.field.prepend_html|default(null) is not null %} | {% set has_prepend_html = ea.field.prepend_html|default(null) is not null %} | ||||
{% set has_append_html = ea.field.append_html|default(null) is not null %} | {% set has_append_html = ea.field.append_html|default(null) is not null %} | ||||
{% set has_input_groups = has_prepend_html or has_append_html %} | {% set has_input_groups = has_prepend_html or has_append_html %} | ||||
#} | |||||
#} | |||||
{% set has_prepend_html = false %} | |||||
{% set has_append_html = false %} | |||||
{% set has_input_groups = false %} | |||||
{% if ea_crud_form.ea_field is defined and ea_crud_form.ea_field is not null %} | |||||
{% set prepend_html = ea_crud_form.ea_field.customOptions.get('prependHtml') %} | |||||
{% set append_html = ea_crud_form.ea_field.customOptions.get('appendHtml') %} | |||||
{% set has_prepend_html = prepend_html is not null %} | |||||
{% set has_append_html = append_html is not null %} | |||||
{% set has_input_groups = has_prepend_html or has_append_html %} | |||||
{% endif %} | |||||
{% set has_prepend_html = false %} | |||||
{% set has_append_html = false %} | |||||
{% set has_input_groups = false %} | |||||
{% if has_input_groups %} | |||||
<div class="input-group">{% endif %} | |||||
{% if has_prepend_html %} | |||||
<div class="input-group-prepend"> | |||||
<span class="input-group-text">{{ prepend_html|raw }}</span> | |||||
</div> | |||||
{% endif %} | |||||
{% if ea_crud_form.ea_field is defined and ea_crud_form.ea_field is not null %} | |||||
{% set prepend_html = ea_crud_form.ea_field.customOptions.get('prependHtml') %} | |||||
{% set append_html = ea_crud_form.ea_field.customOptions.get('appendHtml') %} | |||||
{% set has_prepend_html = prepend_html is not null %} | |||||
{% set has_append_html = append_html is not null %} | |||||
{% set has_input_groups = has_prepend_html or has_append_html %} | |||||
{% endif %} | |||||
{{ form_widget(form) }} | |||||
{% if has_input_groups %} | |||||
<div class="input-group">{% endif %} | |||||
{% if has_prepend_html %} | |||||
<div class="input-group-prepend"> | |||||
<span class="input-group-text">{{ prepend_html|raw }}</span> | |||||
{% if has_append_html %} | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">{{ append_html|raw }}</span> | |||||
</div> | |||||
{% endif %} | |||||
{% if has_input_groups %}</div>{% endif %} | |||||
{% set nullable_fields_fqcn = [ | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField', | |||||
] %} | |||||
{% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %} | |||||
<div class="nullable-control"> | |||||
<label> | |||||
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> | |||||
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }} | |||||
</label> | |||||
</div> | </div> | ||||
{% endif %} | {% endif %} | ||||
{{ form_widget(form) }} | |||||
{% if has_append_html %} | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">{{ append_html|raw }}</span> | |||||
</div> | |||||
{% set help_message = name|sov_trans_admin_help(form.parent.vars.data) %} | |||||
{% if help_message != '' %} | |||||
<small class="form-help">{{ help_message }}</small> | |||||
{% endif %} | {% endif %} | ||||
{% if has_input_groups %}</div>{% endif %} | |||||
{% set nullable_fields_fqcn = [ | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField', | |||||
] %} | |||||
{% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %} | |||||
<div class="nullable-control"> | |||||
<label> | |||||
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> | |||||
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }} | |||||
</label> | |||||
</div> | |||||
{% endif %} | |||||
{% set help_message = name|sov_trans_admin_help(form.parent.vars.data) %} | |||||
{% if help_message != '' %} | |||||
<small class="form-help">{{ help_message }}</small> | |||||
{% endif %} | |||||
{{- form_errors(form) -}} | |||||
{{- form_errors(form) -}} | |||||
</div> | |||||
</div> | </div> | ||||
</div> | |||||
{% endblock form_row %} | |||||
{% endblock form_row %} | |||||
{% block form_label -%} | |||||
{% block form_label -%} | |||||
{% if label is same as(false) -%} | {% if label is same as(false) -%} | ||||
<label>{# the empty <label> is needed to not break the form design #}</label> | |||||
<label>{# the empty <label> is needed to not break the form design #}</label> | |||||
{%- else -%} | {%- else -%} | ||||
{%- if compound is defined and compound -%} | |||||
{%- set element = 'legend' -%} | |||||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | |||||
{%- if compound is defined and compound -%} | |||||
{%- set element = 'legend' -%} | |||||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | |||||
{%- else -%} | |||||
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} | |||||
{%- endif -%} | |||||
{% if required -%} | |||||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |||||
{%- endif -%} | |||||
{% if label is empty -%} | |||||
{%- if label_format is not empty -%} | |||||
{% set label = label_format|replace({ | |||||
'%name%': name, | |||||
'%id%': id, | |||||
}) %} | |||||
{%- else -%} | {%- else -%} | ||||
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} | |||||
{%- endif -%} | |||||
{% if required -%} | |||||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |||||
{%- endif -%} | |||||
{% if label is empty -%} | |||||
{%- if label_format is not empty -%} | |||||
{% set label = label_format|replace({ | |||||
'%name%': name, | |||||
'%id%': id, | |||||
}) %} | |||||
{%- else -%} | |||||
{# {% set label = name|humanize %} #} | |||||
{%- endif -%} | |||||
{# {% set label = name|humanize %} #} | |||||
{%- endif -%} | {%- endif -%} | ||||
{%- endif -%} | |||||
{% set entityNameOrObject = form.parent.vars.data %} | |||||
{% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %} | |||||
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} | |||||
{% endif %} | |||||
{% set entityNameOrObject = form.parent.vars.data %} | |||||
{% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %} | |||||
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} | |||||
{% endif %} | |||||
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) }}</{{ element|default('label') }}> | |||||
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %} | |||||
>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) }} | |||||
</{{ element|default('label') }}> | |||||
{%- endif -%} | {%- endif -%} | ||||
{%- endblock form_label %} | {%- endblock form_label %} | ||||
{% endif %} | {% endif %} | ||||
<div class="col-12"> | <div class="col-12"> | ||||
{# {{ dump(form.vars) }}#} | |||||
{# {{ dump(form.vars.ea_crud_form.ea_field) }}#} | |||||
{# {{ dump(form.vars) }} #} | |||||
{# {{ dump(form.vars.ea_crud_form.ea_field) }} #} | |||||
<div class="input-group"> | <div class="input-group"> | ||||
<div class="input-group-prepend"> | <div class="input-group-prepend"> | ||||
{% if form.parent.vars['row_attr']['data-sortable'] is defined %} | {% if form.parent.vars['row_attr']['data-sortable'] is defined %} | ||||
<i class="fa fa-arrows-alt"></i> | <i class="fa fa-arrows-alt"></i> | ||||
</button> | </button> | ||||
{% endif %} | {% endif %} | ||||
<button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}" | |||||
<button type="button" class="btn btn-primary lc-filemanager-open" | |||||
data-id="{{ form.path.vars.id }}" | |||||
data-toggle="tooltip" title="Sélectionner un fichier" | data-toggle="tooltip" title="Sélectionner un fichier" | ||||
data-target="{{ path('file_manager', {module:1, conf: managerDir})|raw }}"> | data-target="{{ path('file_manager', {module:1, conf: managerDir})|raw }}"> | ||||
<i class="fa fa-folder-open"></i> | <i class="fa fa-folder-open"></i> | ||||
{% endblock file_manager_widget %} | {% endblock file_manager_widget %} | ||||
{% block checkbox_radio_label -%} | {% block checkbox_radio_label -%} | ||||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||||
{%- if widget is defined -%} | {%- if widget is defined -%} | ||||
{% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} | {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} | ||||
{% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} | {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} | ||||
{%- endif -%} | {%- endif -%} | ||||
{%- endif -%} | {%- endif -%} | ||||
{% if attr.disabled is defined and attr.disabled %} | |||||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' disabled')|trim}) -%} | |||||
{% endif %} | |||||
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}> | <label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}> | ||||
{{ widget|raw }} | {{ widget|raw }} | ||||
<span class="checkmark"></span> | <span class="checkmark"></span> | ||||
{# {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} #} | |||||
{# {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} #} | |||||
{% set entityNameOrObject = form.parent.vars.data %} | {% set entityNameOrObject = form.parent.vars.data %} | ||||
{% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %} | {% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %} | ||||
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} | {% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} | ||||
{% endif %} | {% endif %} | ||||
{{- (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) -}} | |||||
<!-- lorsque que le name est un entier "case radio"--> | |||||
{% if name matches '/^\\d+$/' %} | |||||
{{- label|trans({}, 'admin') -}} | |||||
{% else %} | |||||
{{- (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) -}} | |||||
{% endif %} | |||||
{{- form_errors(form) -}} | {{- form_errors(form) -}} | ||||
</label> | </label> | ||||
{%- endif -%} | {%- endif -%} |