<?php
declare(strict_types=1);
namespace App\Admin;
use App\Entity\UnidadNegocio;
use App\Entity\Usuario;
use App\Entity\ValoracionesRelojes;
use App\Enum\EstadoValoracionEnum;
use App\Enum\IdiomaEnum;
use App\Form\Type\HTMLType;
use App\Form\Type\ScriptType;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridInterface;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelListType;
use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType;
use Sonata\AdminBundle\Route\RouteCollectionInterface;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery;
use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter;
use Sonata\Form\Type\CollectionType;
use Sonata\Form\Type\DatePickerType;
use Sonata\Form\Type\DateRangePickerType;
use Sonata\Form\Type\DateTimePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Security\Core\Security;
final class ValoracionAdmin extends AbstractAdmin
{
public function __construct(
string $code,
string $class,
string $baseControllerName,
private Security $security,
private EntityManagerInterface $em
) {
parent::__construct($code, $class, $baseControllerName);
}
// public function configureActionButtons(array $buttonList, string $action, ?object $object = null): array
// {
// $buttonList['stats']['template'] = 'admin/Button/stats_button.html.twig';
// $buttonList['history']['template'] = 'admin/Button/history_button.html.twig';
// $buttonList['clone']['template'] = 'admin/Button/clone_button.html.twig';
// $buttonList['swap']['template'] = 'admin/Button/swap_button.html.twig';
// $buttonList['process']['template'] = 'admin/Button/in_process_button.html.twig';
// return parent::configureActionButtons($buttonList, $action, $object);
// }
public function configureRoutes(RouteCollectionInterface $collection): void
{
$collection->add('stats');
$collection->add('history');
$collection->add('clone');
$collection->add('swap');
$collection->add('in-process');
$collection->add('sales-management');
$collection->add('switch-operacion');
parent::configureRoutes($collection);
}
public function configureExportFields(): array
{
return [
$this->getTranslator()->trans('export.valoracion.IDperseo') => 'valoracion.IDperseo',
$this->getTranslator()->trans('export.valoracion.fecha') => 'valoracion.fechaString',
$this->getTranslator()->trans('export.valoracion.unidad_negocio') => 'valoracion.unidadNegocio',
$this->getTranslator()->trans('export.valoracion.usuario') => 'valoracion.usuario',
$this->getTranslator()->trans('export.valoracion.canal') => 'valoracion.canal',
$this->getTranslator()->trans('export.valoracion.cliente') => 'valoracion.cliente',
$this->getTranslator()->trans('export.valoracion.tipo_cliente') => 'valoracion.tipoCliente',
$this->getTranslator()->trans('export.valoracion.exportacion') => 'valoracion.exportacion',
$this->getTranslator()->trans('export.valoracion.idioma') => 'valoracion.idioma',
$this->getTranslator()->trans('export.valoracion.fecha_enviada') => 'valoracion.fechaEnviadaString',
$this->getTranslator()->trans('export.valoracion.fecha_aceptacion') => 'valoracion.fechaAceptacionString',
$this->getTranslator()->trans('export.valoracion.fecha_rechazo') => 'valoracion.fechaRechazoString',
$this->getTranslator()->trans('export.valoracion.fecha_tramitacion') => 'valoracion.fechaTramitacionString',
$this->getTranslator()->trans('export.valoracion.info_tramitacion') => 'valoracion.infoTramitacion',
$this->getTranslator()->trans('export.valoracion.precio_pagar') => 'valoracion.precioPagar',
$this->getTranslator()->trans('export.valoracion.info_valoracion') => 'valoracion.infoValoracion',
$this->getTranslator()->trans('export.valoracion.relojes_sin_stock') => 'valoracion.exportValoracionesRelojesSinStock',
$this->getTranslator()->trans('export.valoracion.relojes_stock') => 'valoracion.exportValoracionesRelojesStock',
];
}
protected function configureDefaultSortValues(array &$sortValues): void
{
parent::configureDefaultSortValues($sortValues);
$sortValues[DatagridInterface::PER_PAGE] = 50;
}
protected function configureDefaultFilterValues(array &$filterValues): void
{
$filterValues = [
'usuario' => [
'type' => EqualOperatorType::TYPE_EQUAL,
'value' => 0
],
'estado' => [
'type' => EqualOperatorType::TYPE_EQUAL,
'value' => [EstadoValoracionEnum::ESTADO_ABIERTA, EstadoValoracionEnum::ESTADO_ESPERA, EstadoValoracionEnum::ESTADO_ACEPTADA]
]
];
parent::configureDefaultFilterValues($filterValues);
}
protected function configureDatagridFilters(DatagridMapper $filter): void
{
if(!@$_REQUEST['filter'][DatagridInterface::PER_PAGE]) $this->getDatagrid()->setValue(DatagridInterface::PER_PAGE, null, 50);
//$existFilter = !empty($this->getRequest()->getSession()->get('admin.valoracion.filter.parameters'));
$choicesUsuarioS = [$this->em->getReference(Usuario::class, 0)];
if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {
$choicesUsuarioS = array_merge($choicesUsuarioS,
$this->em->getRepository(Usuario::class)->findAll() ?? []);
} else {
$choicesUsuarioS = array_merge($choicesUsuarioS,
$this->em->getRepository(Usuario::class)->getUsuariosByUnidadNegocio($this->security->getUser()->getUsuario()?->getUnidadNegocio()));
}
$filter
->add('busqueda', CallbackFilter::class, [
'label' => false,
'attr' => [
'class' => 'filter-to-navbar-left filter-to-navbar',
'data-order' => '1',
'placeholder' => 'filter.placeholder.busqueda',
],
'callback' => function ($queryBuilder, $alias, $field, $value) {
if (!$value->hasValue()) {
return;
}
$this->em->getRepository(ValoracionesRelojes::class)->cbFilter($queryBuilder, $alias, $field,
$value);
return true;
},
])
->add('estado', CallbackFilter::class, [
'label' => false,
'attr' => [
'class' => 'filter-to-navbar-right filter-to-navbar',
'data-order' => '2',
'data-id' => 'filter-filters'
],
'callback' => function ($queryBuilder, $alias, $field, $value) {
if (!$value->hasValue()) {
return;
}
$this->em->getRepository(ValoracionesRelojes::class)->cbFilter($queryBuilder, $alias, $field,
$value);
return true;
},
], [
'field_type' => ChoiceType::class,
'field_options' => [
'choices' => array_keys(EstadoValoracionEnum::getEstados()),
'multiple' => true,
'expanded' => true,
'choice_label' => function ($choice, $key, $value) {
return EstadoValoracionEnum::getEstado($choice);
},
/*'choice_attr' => function ($choice, $key, $value) use ($existFilter){
if (!$existFilter && !$this->getRequest()->get('filter') && in_array($value, [EstadoValoracionEnum::ESTADO_ABIERTA, EstadoValoracionEnum::ESTADO_ESPERA, EstadoValoracionEnum::ESTADO_ACEPTADA])) {
return [
'checked' => true
];
}
return [];
},*/
]
])
->add('usuario', CallbackFilter::class, [
'label' => false,
'attr' => [
'class' => 'filter-to-navbar-right filter-to-navbar',
'data-order' => '1',
'data-id' => 'filter-usuario-filters'
],
'callback' => function ($queryBuilder, $alias, $field, $value) {
if (!$value->hasValue()) {
return;
}
$this->em->getRepository(ValoracionesRelojes::class)->cbFilter($queryBuilder, $alias, $field,
$value);
return true;
},
], [
'field_type' => ChoiceType::class,
'field_options' => [
'choices' => $choicesUsuarioS,
'multiple' => false,
'expanded' => true,
'choice_value' => function ($choice) {
return $choice ? $choice->getId() : 0;
},
'choice_label' => function ($choice, $key, $value) {
return $value != 0 ? $choice->getUser()->getIniciales() : 'filter.valoracion.usuarios.label.all';
},
/*'choice_attr' => function ($choice, $key, $value) {
if(!$this->getRequest()->get('filter')) {
return [
'checked' => $value == 0
];
}
return [];
},*/
]
]);
// if($this->security->isGranted('ROLE_SUPER_ADMIN')) {
// $filter
// ->add('unidadNegocio', CallbackFilter::class, [
// 'label' => false,
// 'attr' => [
// 'data-order' => '1',
// 'class' => '',
// 'placeholder' => 'filter.valoracion.placeholder.unidad_negocio',
// ],
// 'callback' => function($queryBuilder, $alias, $field, $value)
// {
// if (!$value->hasValue()) return;
//
// $this->em->getRepository(ValoracionesRelojes::class)->cbFilter($queryBuilder, $alias, $field, $value);
//
// return true;
// }
// ]);
// }
$filter
->add('fecha', CallbackFilter::class, [
'label' => false,
'attr' => [
'data-order' => '2',
'class' => 'filter-date-range'
],
'field_type' => DateRangePickerType::class,
'field_options' => [
'field_options_start' => [
'label' => false,
'attr' => ['placeholder' => 'filter.valoracion.placeholder.fecha_start']
],
'field_options_end' => [
'label' => false,
'attr' => ['placeholder' => 'filter.valoracion.placeholder.fecha_end']
]
],
'callback' => function ($queryBuilder, $alias, $field, $value) {
if (!$value->hasValue()) {
return;
}
$this->em->getRepository(ValoracionesRelojes::class)->cbFilter($queryBuilder, $alias, $field,
$value);
return true;
}
]);
}
protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterface
{
$filterBusquedaRequest = $this->getRequest()->get('filter')['busqueda'] ?? [];
$filterBusquedaSession = $this->getRequest()->getSession()->get('admin.valoracion.filter.parameters')['busqueda'] ?? [];
$hasFilterBusqueda = @$filterBusquedaRequest['value'] || @$filterBusquedaSession['value'];
$query = $this->em->getRepository(ValoracionesRelojes::class)->qbQuery($this->security->getUser()?->getUsuario()?->getUnidadNegocio(), $hasFilterBusqueda,
!$this->getRequest()->get('filter') && empty($this->getRequest()->getSession()->get('admin.valoracion.filter.parameters')));
return parent::configureQuery(new ProxyQuery($query));
}
protected function configureListFields(ListMapper $list): void
{
$list
->add('valoracion.IDperseo', null, [
'label' => 'list.valoracion.label.id_perseo',
'header_style' => 'width: 110px',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'IDperseo'],
'sort_parent_association_mappings' => [['fieldName' => 'valoracion']],
// 'modal-link' => true,
// 'modal-attr' => [
// 'data-modal_show_class' => 'valoracion',
// 'data-modal_show_title' => $this->getTranslator()->trans('list.valoracion.modal_show.title.id_perseo')
// ],
'template' => 'admin/CRUD/Valoracion/list_field_valoracion.html.twig'
])
/*->add('valoracion.fecha', 'datetime', [
'label' => 'list.valoracion.label.fecha',
'header_style' => 'width: 90px',
'format' => 'd/m/Y',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'fecha'],
'sort_parent_association_mappings' => [['fieldName' => 'valoracion']]
])*/
->add('valoracion.estado', null, [
'identifier' => false,
'label' => 'list.valoracion.label.estado',
'header_style' => 'width: 75px',
'template' => 'admin/CRUD/Valoracion/list_field_valoracion_estado.html.twig',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'nombre'],
'sort_parent_association_mappings' => [['fieldName' => 'valoracion'],['fieldName' => 'estado']]
])
->add('valoracion.estadoFecha', 'datetime', [
'label' => 'list.valoracion.label.fecha_estado',
'header_style' => 'width: 90px;word-break: break-word;',
'format' => 'd/m/Y',
'template' => 'admin/CRUD/Valoracion/list_field_valoracion_estado_fecha.html.twig'
])
->add('relojMarca', null, [
'label' => 'list.valoracion.label.marca',
'header_style' => 'width: 75px',
'collapse' => [
// height in px
'height' => 20,
// content of the "read more" link
'more' => '[+]',
// content of the "read less" link
'less' => '[-]',
],
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'nombre'],
'sort_parent_association_mappings' => [['fieldName' => 'relojMarca']],
'template' => 'admin/CRUD/list_field_collapse.html.twig',
])
->add('relojModelo1', null, [
'label' => 'list.valoracion.label.modelo1',
//'associated_property' => 'relojModelo1',
//'collapse' => true,
'header_style' => 'width: 75px',
'collapse' => [
// height in px
'height' => 20,
// content of the "read more" link
'more' => '[+]',
// content of the "read less" link
'less' => '[-]',
],
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'relojModelo1'],
'sort_parent_association_mappings' => [],
'template' => 'admin/CRUD/list_field_collapse.html.twig',
])
->add('relojRef1', null, [
'label' => 'list.valoracion.label.ref1',
'header_style' => 'width: 75px',
'collapse' => [
// height in px
'height' => 20,
// content of the "read more" link
'more' => '[+]',
// content of the "read less" link
'less' => '[-]',
],
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'relojRef1'],
'sort_parent_association_mappings' => [],
'template' => 'admin/CRUD/list_field_collapse.html.twig',
])
->add('precioPromocion', null, [
'label' => 'list.valoracion.label.precio_promocion',
'header_style' => 'width: 90px',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'precioPromocion'],
'sort_parent_association_mappings' => [],
'template' => 'admin/CRUD/list_field_currency.html.twig',
])
->add('margenDeseado', null, [
'label' => 'list.valoracion.label.margen_deseado',
'header_style' => 'width: 65px',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'margenDeseado'],
'sort_parent_association_mappings' => [],
'template' => 'admin/CRUD/list_field_percent.html.twig'
])
->add('precioPagar', null, [
'label' => 'list.valoracion.label.precio_pagar',
'header_style' => 'width: 90px',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'precioPagar'],
'sort_parent_association_mappings' => [],
'template' => 'admin/CRUD/list_field_currency.html.twig'
])
->add('valoracion.cliente', null, [
'label' => 'list.valoracion.label.cliente',
'header_style' => 'width: 75px',
'modal-link' => true,
'modal-attr' => [
'data-modal_show_class' => 'cliente',
'data-modal_show_title' => $this->getTranslator()->trans('list.valoracion.modal_show.title.cliente')
],
'collapse' => [
// height in px
'height' => 20,
// content of the "read more" link
'more' => '[+]',
// content of the "read less" link
'less' => '[-]',
],
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'razonSocial'],
'sort_parent_association_mappings' => [['fieldName' => 'valoracion'], ['fieldName' => 'cliente']],
'template' => 'admin/CRUD/list_field_cliente.html.twig'
])
->add('valoracion.canal', null, [
'label' => 'list.valoracion.label.canal',
'header_style' => 'width: 80px',
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'nombre'],
'sort_parent_association_mappings' => [['fieldName' => 'valoracion'], ['fieldName' => 'canal']],
]);
if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {
$list
->add('valoracion.usuario', null, [
'label' => 'list.valoracion.label.usuario',
'header_style' => 'width: 75px',
'route' => [
'name' => 'edit'
],
'modal-link' => true,
'modal-attr' => [
'data-modal_show_class' => 'usuario',
'data-modal_show_title' => $this->getTranslator()->trans('list.valoracion.modal_show.title.usuario')
],
'collapse' => [
// height in px
'height' => 20,
// content of the "read more" link
'more' => '[+]',
// content of the "read less" link
'less' => '[-]',
],
'sortable' => true,
'sort_field_mapping' => ['fieldName' => 'nombre'],
'sort_parent_association_mappings' => [['fieldName' => 'valoracion'], ['fieldName' => 'usuario'], ['fieldName' => 'user']],
'template' => 'admin/CRUD/list_field_collapse.html.twig',
]);
}
$list
->add(ListMapper::NAME_ACTIONS, null, [
'header_style' => 'width: 75px',
'actions' => [
// 'edit' => ['template' => 'admin/CRUD/Valoracion/action_edit.html.twig'],
'show' => [
'template' => 'admin/CRUD/Valoracion/action_show.html.twig',
'link_parameters' => [
'modal-attr' => [
'data-modal_show_class' => 'valoracion',
'data-modal_show_title' => $this->getTranslator()->trans('list.valoracion.modal_show.title.id_perseo')
]
]
],
],
]);
}
protected function configureFormFields(FormMapper $form): void
{
$object = $this->getSubject();
$idioma = IdiomaEnum::IDIOMA_ES;
$fecha = new DateTime('now');
$user = $this->security->getUser();
$usuario = $user?->getUsuario();
$unidadNegocio = $usuario?->getUnidadNegocio();
$classAccessAdmin = $this->security->isGranted('ROLE_SUPER_ADMIN') ? 'access-admin' : '';
if ($unidadNegocio) {
$unidadNegocio = $this->em
->getRepository(UnidadNegocio::class)
->find($unidadNegocio->getId());
}
if ($usuario) {
$usuario = $this->em
->getRepository(Usuario::class)
->find($usuario->getId());
}
if (isset($_GET['modal'])) {
$form
->add('fecha', DateTimePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha',
'disabled' => $this->isDisabled(),
'format' => 'dd-MM-yyyy HH:mm',
'attr' => [
'placeholder' => 'form.valoracion.placeholder.fecha',
]
])
->add('fechaEnviada', DateTimePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha_enviada',
'disabled' => $this->isDisabled(),
'format' => 'dd-MM-yyyy HH:mm',
'attr' => [
'placeholder' => 'form.valoracion.placeholder.fecha_enviada',
]
])
->add('fechaAceptacion', DateTimePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha_aceptacion',
'disabled' => $this->isDisabled(),
'format' => 'dd-MM-yyyy HH:mm',
'attr' => [
'placeholder' => 'form.valoracion.placeholder.fecha_aceptacion',
]
])
->add('fechaRechazo', DateTimePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha_rechazo',
'disabled' => $this->isDisabled(),
'format' => 'dd-MM-yyyy HH:mm',
'attr' => [
'placeholder' => 'form.valoracion.placeholder.fecha_rechazo',
'class' => 'bolder text-canceled'
]
])
->add('fechaTramitacion', TextType::class, [
'label' => false,
'data' => $object->getFechaTramitacion()?->format('d-m-Y'),
'attr' => [
'placeholder' => 'form.valoracion.placeholder.fecha_tramitacion',
'readonly' => true
]
])
->add('valoracionesRelojesSinStocks', CollectionType::class, [
'label' => false,
'row_attr' => [
'data-title_modal_record_delete' => $this->getTranslator()->trans('title.modal.record.delete.valoraciones_relojes'),
'data-message_modal_record_delete' => $this->getTranslator()->trans('message.modal.record.delete.valoraciones_relojes'),
],
'by_reference' => true,
'btn_add' => null,
'type_options' => ['delete' => false],
], [
'edit' => 'inline',
'inline' => 'table',
'attr' => [
'class' => 'table-valoraciones-relojes-sin-stocks table-view-card table-valoraciones-relojes-sin-stocks-view-card table-view-multiple-card'
],
'admin_code' => 'admin.valoraciones_relojes_sin_stock',
])
->add('valoracionesRelojesStocks', CollectionType::class, [
'label' => false,
'row_attr' => [
'data-title_modal_record_delete' => $this->getTranslator()->trans('title.modal.record.delete.valoraciones_relojes'),
'data-message_modal_record_delete' => $this->getTranslator()->trans('message.modal.record.delete.valoraciones_relojes'),
],
'by_reference' => true,
'btn_add' => null,
'type_options' => ['delete' => false],
], [
'edit' => 'inline',
'inline' => 'table',
'attr' => [
'class' => 'table-valoraciones-relojes-stocks table-view-card table-valoraciones-relojes-stocks-view-card table-view-multiple-card table-view-carousel'
],
'admin_code' => 'admin.valoraciones_relojes_stock',
])
// ->add('valoracionesRelojes', CollectionType::class, [
// 'label' => false,
// 'by_reference' => false,
// 'btn_add' => false,
// 'type_options' => ['delete' => false],
// ], [
// 'edit' => 'inline',
// 'inline' => 'table',
// 'attr' => [
// 'class' => 'table-view-card table-valoraciones-relojes-view-card display-collection-type table-view-multiple-card',
// ],
// ])
->add('infoValoracion', null, [
'label' => false,
'disabled' => $this->isDisabled(),
'attr' => [
'placeholder' => 'form.valoracion.placeholder.info_valoracion',
]
])
->add('precioPagar', null, [
'label' => false,
'disabled' => $this->isDisabled(),
'attr' => [
'placeholder' => 'form.valoracion.placeholder.precio_pagar',
'class' => 'numeric currencies'
]
])
;
} else {
$form
->with('with_valoracion', [
'label' => false
])
->add('IDperseo', null, [
'label' => false,
'required' => false,
'disabled' => true,
'attr' => [
'placeholder' => 'form.valoracion.placeholder.id_perseo',
],
/*], [
'more_info' => [
'data-input-field' => 'info_valoracion',
'data-input-field-value' => $this->getSubject()->getInfoValoracion()
]*/
])
->add('fecha', DateTimePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha',
//'disabled' => true,
'format' => 'dd-MM-yyyy HH:mm',
'data' => $object->getFecha() ? $object->getFecha() : $fecha,
'attr' => [
'readonly' => true,
'placeholder' => 'form.valoracion.placeholder.fecha',
],
'row_attr' => [
'class' => 'readonly',
]
])
->add('unidadNegocio', null, [
'label' => false,
//'disabled' => true,
'placeholder' => 'form.valoracion.placeholder.unidad_negocio',
'data' => $object->getUnidadNegocio() ? $object->getUnidadNegocio() : $unidadNegocio,
'choice_attr' => function ($val, $key, $index)
{
return $val?->getColor() ? [
'data-color' => $val->getColor(),
'style' => 'color: ' . $val->getColor() . ';',
] : [];
},
'row_attr' => [
'class' => 'color-unidad-negocio'
]
/*'attr' => [
'readonly' => $this->isReadOnly(),
],
'row_attr' => [
'class' => $this->isReadOnly()?'readonly':'',
]*/
])
->add('usuario', null, [
'label' => false,
//'disabled' => true,
'placeholder' => 'form.valoracion.placeholder.usuario',
'data' => $object->getUsuario() ? $object->getUsuario() : $usuario,
'attr' => [
'readonly' => $this->isReadOnly(),
],
'row_attr' => [
'class' => $this->isReadOnly()?'readonly':'',
]
])
->add('canal', ModelListType::class, [
'label' => false,
'attr' => [
'data-max_length' => 15
],
'row_attr' => [
'class' => 'display-model-list-type create-display-none'
],
'btn_delete' => false,
], [
'placeholder' => 'form.valoracion.placeholder.canal',
'link_parameters' => [
'nav_prometeo' => true,
'model_list_type' => 'canal',
'action_create_not_list' => false,
]
])
->add('cliente', ModelListType::class, [
'label' => false,
'attr' => [
'data-max_length' => 24
],
'row_attr' => [
'class' => "display-model-list-type create-display-none $classAccessAdmin"
],
'btn_delete' => false,
], [
'placeholder' => 'form.valoracion.placeholder.cliente',
'link_parameters' => [
'nav_prometeo' => true,
'model_list_type' => 'cliente',
'action_create_not_list' => false,
]
])
->add('tipoCliente', null, [
'label' => 'form.valoracion.label.tipo_cliente'
])
->add('exportacion', null, [
'label' => 'form.valoracion.label.exportacion'
])
->add('infoValoracion', null, [
'label' => false,
'attr' => [
'placeholder' => 'form.valoracion.placeholder.info_valoracion'
],
'row_attr' => [
'class' => $object?->getInfoValoracion() ? 'more-info more-info-modal' : 'more-info more-info-modal empty',
'more_info_class' => 'more-info-input-wrap more-info-input-wrap-modal more-info-input-wrap-right',
],
])
->add('idioma', ChoiceType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.idioma',
'choices' => array_flip(IdiomaEnum::getIdiomas()),
'data' => $object->getIdioma() ? $object->getIdioma() : $idioma,
])
->end()
/*->with('with_help_usuario', [
'label' => 'form.valoracion.with_help_usuario',
])
->add('content', HTMLType::class, [
'label' => false,
'template' => 'admin/valoraciones/help_usuario.html.twig'
])
->end()*/
->with('with_valoraciones_relojes_sin_stock', [
'label' => false//'form.valoracion.with_valoraciones_relojes_sin_stock.label',
//'class' => 'with-collapse col-md-12'
])
->add('valoracionesRelojesSinStocks', CollectionType::class, [
'label' => false,
'row_attr' => [
'data-title_modal_record_delete' => $this->getTranslator()->trans('title.modal.record.delete.valoraciones_relojes'),
'data-message_modal_record_delete' => $this->getTranslator()->trans('message.modal.record.delete.valoraciones_relojes'),
],
'by_reference' => false,
'btn_add' => 'link_add_valoraciones_relojes_sin_stocks'
], [
'edit' => 'inline',
'inline' => 'table',
'attr' => [
'class' => 'table-valoraciones-relojes-sin-stocks table-view-card table-valoraciones-relojes-sin-stocks-view-card table-view-multiple-card'
],
'admin_code' => 'admin.valoraciones_relojes_sin_stock',
])
->add('scriptEventOnChange', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/reloj_event_on_change.html.twig'
])
;
if (!$this->isHidden()) {
$form
->add('scriptDeleteImagen', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/delete_imagen.html.twig'
])
->add('scriptCalcularMargenPromocion', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/calcular_margen_promocion.html.twig'
])
->add('scriptCalcularMargenMinimo', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/calcular_margen_minimo.html.twig'
])
->add('scriptCalcularPrecioCosteTotal', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/calcular_precio_oferta.html.twig'
])
->add('scriptCalcularCostesEventOnChangePrecio', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/calcular_costes_event_on_change_precio.html.twig'
])
->add('scriptControlPrecioReferencia', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/control_precio_referencia.html.twig'
])
->add('scriptControlCostesTotal', ScriptType::class, [
'template' => 'SCRIPTS/ValoracionesRelojesSinStock/control_costes_total.html.twig'
]);
}
$form
->end()
->with('with_valoraciones_relojes_stock', [
'label' => null,//'form.valoracion.with_valoraciones_relojes_stock.label',
'class' => 'hide col-md-12'//'with-collapse col-md-12'
])
->add('valoracionesRelojesStocks', CollectionType::class, [
'label' => false,
'row_attr' => [
// 'class' => 'hide',
'data-title_modal_record_delete' => $this->getTranslator()->trans('title.modal.record.delete.valoraciones_relojes'),
'data-message_modal_record_delete' => $this->getTranslator()->trans('message.modal.record.delete.valoraciones_relojes'),
],
'by_reference' => false,
'btn_add' => 'link_add_valoraciones_relojes_stocks'
], [
'edit' => 'inline',
'inline' => 'table',
'attr' => [
'class' => 'table-valoraciones-relojes-stocks table-view-card table-valoraciones-relojes-stocks-view-card table-view-multiple-card'
],
'admin_code' => 'admin.valoraciones_relojes_stock',
])
->end()
->with('with_resumen', [
'label' => false
])
->add('fechaEnviada', DatePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha_enviada',
'format' => 'dd-MM-yyyy',
'row_attr' => [
'class' => 'control-fechas-resumen',
],
'attr' => [
'placeholder' => 'form.valoracion.placeholder.fecha_enviada',
'data-control_fecha_title' => null,
'data-control_fecha_message' => $this->getTranslator()->trans('message.control.fecha.valoraciones_relojes.fecha_enviada'),
],
'datepicker_options' => [
'useCurrent' => false
]
])
->add('fechaAceptacion', DatePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha_aceptacion',
'format' => 'dd-MM-yyyy',
'row_attr' => [
'class' => 'control-fechas-resumen readonly',
//'style' => 'pointer-events: none;'
],
'attr' => [
'readonly' => true,
'placeholder' => 'form.valoracion.placeholder.fecha_aceptacion',
],
'datepicker_options' => [
'useCurrent' => false,
]
])
->add('fechaRechazo', DatePickerType::class, [
'label' => false,
'placeholder' => 'form.valoracion.placeholder.fecha_rechazo',
'format' => 'dd-MM-yyyy',
'row_attr' => [
'class' => 'control-fechas-resumen bolder text-canceled',
//'style' => 'pointer-events: none;'
],
'attr' => [
'readonly' => false,
'placeholder' => 'form.valoracion.placeholder.fecha_rechazo',
],
'datepicker_options' => [
'useCurrent' => false,
]
])
->add('fechaTramitacion', TextType::class, [
'label' => false,
'disabled' => true,
'data' => $object->getFechaTramitacion()?->format('d-m-Y'),
'attr' => [
'readonly' => true,
'placeholder' => 'form.valoracion.placeholder.fecha_tramitacion',
]
])
->add('infoTramitacion', null, [
'label' => false,
'attr' => [
'placeholder' => 'form.valoracion.placeholder.info_tramitacion'
],
'row_attr' => [
'class' => $object?->getInfoTramitacion() ? 'more-info more-info-modal' : 'more-info more-info-modal empty',
'more_info_class' => 'more-info-input-wrap more-info-input-wrap-modal more-info-input-wrap-right',
]
])
->add('precioPagar', null, [
'label' => false,
'attr' => [
'readonly' => true,
'placeholder' => 'form.valoracion.placeholder.precio_pagar',
'class' => $object?->getPrecioPagar() < 0 ? 'numeric currencies currency-negative' : 'numeric currencies currency-positive'
]
])
->add('scriptCalcularPrecioPagar', ScriptType::class, [
'template' => 'SCRIPTS/Valoracion/calcular_precio_pagar.html.twig'
])
->add('scriptRecalculosDeleteCollections', ScriptType::class, [
'template' => 'SCRIPTS/Valoracion/recalculos_delete_collections.html.twig'
])
->add('scriptControlFechasResumen', ScriptType::class, [
'template' => 'SCRIPTS/Valoracion/control_fechas_resumen.html.twig'
])
->end();
}
}
protected function configureShowFields(ShowMapper $show): void
{
$show
->add('id');
}
private function isReadOnly()
{
return !$this->security->isGranted('ROLE_SUPER_ADMIN');
}
private function isDisabled()
{
return isset($_GET['modal']);
}
private function isHidden()
{
return isset($_GET['modal']);
}
}