<?php
namespace AdminBundle\Admin\Vehicles\Passenger;
use CoreBundle\Entity\AutoRiaOptions;
use CoreBundle\Entity\Vehicles\Characteristic;
use CoreBundle\Model\Api\AutoRia\AutoRia;
use DateTime;
use Exception;
use AdminBundle\Admin\Vehicles\BaseUsedVehicleAdmin;
use AdminBundle\Form\Type\ContentType;
use CoreBundle\Entity\Vehicles\AutoRiaTxn;
use CoreBundle\Entity\Vehicles\Equipment;
use CoreBundle\Entity\Vehicles\RecommendGroup;
use CoreBundle\Entity\Vehicles\Variation;
use CoreBundle\Entity\Vehicles\VariationCharacteristic;
use CoreBundle\Entity\Vehicles\Vehicle;
use CoreBundle\Entity\Vehicles\VehicleItem;
use CoreBundle\Model\Vehicles\Characteristic as CharacteristicModel;
use CoreBundle\Model\Vehicles\VehicleType;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\OptimisticLockException;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelListType;
use Sonata\AdminBundle\Form\Type\ModelType;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Route\RouteCollectionInterface;
use Sonata\Form\Type\CollectionType;
use Sonata\MediaBundle\Form\Type\MediaType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class UsedVehicleAdmin extends BaseUsedVehicleAdmin
{
protected $baseRouteName = 'used-vehicle-passenger';
protected $baseRoutePattern = 'used-vehicle-passenger-action';
protected $datagridValues = [
'_page' => 1,
'_sort_order' => 'DESC',
'_sort_by' => 'id',
];
protected SessionInterface $session;
protected \CoreBundle\Factory\Vehicle $vehicleFactory;
public function setExtraServices(SessionInterface $session, \CoreBundle\Factory\Vehicle $vehicleFactory): void
{
$this->session = $session;
$this->vehicleFactory = $vehicleFactory;
}
protected function getVehicleType(): int
{
return VehicleType::PASSENGER_TYPE;
}
protected function getVariationAdminCode()
{
return 'admin.vehicles.passenger_variation';
}
/**
* @param array $buttonList
* @param string $action
* @param null $object
* @return array
*/
public function configureActionButtons(array $buttonList, string $action, $object = null): array
{
$list = parent::configureActionButtons($buttonList, $action, $object);
$list['import']['template'] = '@AdminBundle/admin/export_used_vehicles_button.html.twig';
return $list;
}
/**
* @param RouteCollectionInterface $collection
*/
protected function configureRoutes(RouteCollectionInterface $collection): void
{
parent::configureRoutes($collection);
$collection->add('setFilled', $this->getRouterIdParameter() . '/set-filled');
$collection->add('exportUsedVehicles', 'export-used');
$collection->add('exportUsedSpecification', $this->getRouterIdParameter() . '/export-used-specification');
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
parent::configureDatagridFilters($datagridMapper);
$datagridMapper->add(
'is_not_filled',
null,
['label' => 'Заповненість авто'],
ChoiceType::class,
[
'choices' => [
'Недозаповнені' => 1,
'Заповнені' => 0
]
]
);
}
/**
* @param Vehicle $object
* @throws NonUniqueResultException
* @throws OptimisticLockException
*/
public function preUpdate($object): void
{
parent::preUpdate($object);
if ($object->getPreview() && $object->getGallery()) {
$object->setIsNotFilled(0);
}
$VehicleItem = $object->getVehicleItems() ? $object->getVehicleItems()[0] : null;
if (($object->getState() == 0 || ($VehicleItem && $VehicleItem->getSold())) && $object->getRiaId() && $object->getDealer()->getRiaUserId()) {
$result = $this->autoRia->deleteVehicle($object->getRiaId());
$AutoRiaTxn = new AutoRiaTxn();
$AutoRiaTxn->setDateCreate(new DateTime());
$AutoRiaTxn->setType('delete');
$AutoRiaTxn->setRequest($object->getRiaId());
if ($result) {
$AutoRiaTxn->setResponse(json_encode($result));
}
$AutoRiaTxn->setVehicle($object);
$AutoRiaTxn->setUser($this->getUser());
$this->getModelManager()->getEntityManager(AutoRiaTxn::class)->persist($AutoRiaTxn);
$this->getModelManager()->getEntityManager(AutoRiaTxn::class)->flush();
$object->setRiaId(null);
//TODO refactor this to correct entity data
$object->setRiaLevel(null);
$object->setRiaPeriod(null);
$object->setRiaPublicationDate(null);
$object->setRiaTopPublicationDate(null);
$object->setRiaIsNotified(null);
}
if ($object->getState() && $object->getDealer()->getRiaUserId()) {
$isUpdateAutoRia = false;
$originalVehicleData =
$this->getModelManager()
->getEntityManager(Vehicle::class)
->getUnitOfWork()
->getOriginalEntityData($object);
if (
($originalVehicleData['model'] && $object->getModel()->getId() != $originalVehicleData['model']->getId()) ||
($object->getVin() != $originalVehicleData['vin']) ||
($object->getState() != $originalVehicleData['state'])
) {
//TODO remove magic numbers
if ($object->getDealer()->getId() == 6 && !$object->getIsNotFilled() && !$VehicleItem->getSold()) {
$this->publish($object);
}
}
$originalVehicleItemData =
$this->getModelManager()
->getEntityManager(VehicleItem::class)
->getUnitOfWork()
->getOriginalEntityData($object->getVehicleItems()->first());
if (
($object->getVehicleItems()->first()->getPrice() != $originalVehicleItemData['price']) ||
($object->getVehicleItems()->first()->getAltPrice() != $originalVehicleItemData['alt_price']) ||
($object->getVehicleItems()->first()->getYear() != $originalVehicleItemData['year']) ||
($object->getVehicleItems()->first()->getMileage() != $originalVehicleItemData['mileage']) ||
($object->getRiaOptions() != $originalVehicleData['ria_options'])
) {
//TODO remove magic numbers
if ($object->getDealer()->getId() == 6 && !$object->getIsNotFilled() && !$VehicleItem->getSold()) {
$this->publish($object);
}
}
/** @var VariationCharacteristic $characteristic */
foreach ($object->getVariations()->first()->getCharacteristics() as $characteristic) {
if ($isUpdateAutoRia) {
continue;
}
if (
in_array(
$characteristic->getCharacteristic()->getModelUnique(),
[
CharacteristicModel::BODY_TYPE_UNIQUE_ID,
CharacteristicModel::FUEL_TYPE_UNIQUE_ID,
CharacteristicModel::DRI_TYPE_UNIQUE_ID,
CharacteristicModel::TRANSMISSION_TYPE_UNIQUE_ID,
CharacteristicModel::BODY_COLOR,
CharacteristicModel::SEATS_COUNT_UNIQUER_ID,
CharacteristicModel::DOORS_COUNT_UNIQUER_ID
]
)
) {
$originalCharacteristic =
$this->getModelManager()
->getEntityManager(Characteristic::class)
->getUnitOfWork()
->getOriginalEntityData($characteristic);
if (
(
$characteristic->getCharacteristicValue() &&
$characteristic->getCharacteristicValue()->getId() !=
$originalCharacteristic['characteristic_value_id']
) ||
($characteristic->getValue('ru') != $originalCharacteristic['value_ru'])
) {
$isUpdateAutoRia = true;
}
}
}
//TODO remove magic numbers
if ($isUpdateAutoRia && $object->getDealer()->getId() == 6 && !$object->getIsNotFilled() && !$VehicleItem->getSold())
{
$this->publish($object);
}
}
}
/**
* @param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper): void
{
$User = $this->getUser();
if (!$Dealer = $User->getDealer()) {
throw new AccessDeniedException('User without dealer');
}
$vehicle = $this->getSubject();
if (!$vehicle) {
$vehicle = new Vehicle();
}
/** @var Vehicle $vehicle */
//TODO remove magic numbers
if (!$vehicle->getId()) {
$vehicle->setState(1);
$vehicle->setIsUsed(1);
$equipment = new Equipment();
$equipment->setState(1);
$equipment->setVehicle($vehicle);
$vehicle->addEquipment($equipment);
$variation = new Variation();
$variation->setState(1);
$variation->setVehicle($vehicle);
$vehicle->addVariation($variation);
$VehicleItem = new VehicleItem();
$VehicleItem->setVariation($variation);
$VehicleItem->setState(1);
$VehicleItem->setEquipment($equipment);
$variation->addVehicleItem($VehicleItem);
$vehicle->addVehicleItem($VehicleItem);
}
//TODO remove magic numbers
if (!$vehicle->getVariations()->count()) {
$variation = new Variation();
$variation->setState(1);
$variation->setVehicle($vehicle);
$vehicle->addVariation($variation);
$VehicleItem = new VehicleItem();
$VehicleItem->setVariation($variation);
$VehicleItem->setState(1);
$VehicleItem->setEquipment($equipment);
$variation->addVehicleItem($VehicleItem);
$vehicle->addVehicleItem($VehicleItem);
}
$formMapper
->tab('Основная информация')
->with('Контент', ['class' => 'col-lg-6'])
->add('content', ContentType::class, ['label' => false], [
'edit' => 'inline',
'sortable' => 'position',
])
->add('vehicle_items.first.programm', TextType::class, ['label' => 'Программа', 'required' => false])
->end()
->with('Доп. информация', ['class' => 'col-lg-6']);
if($vehicle->getVehicleItems()->first()->getDateOfSale()){
$formMapper
->add(
'vehicle_items.first.date_of_sale',
DateTimeType::class,
['label' => 'Дата продажи', 'required' => false, 'attr' => ['disabled' => 'disabled'],
'widget' => 'single_text',
'format' => 'yyyy-MM-dd'
]
);
}
if ($this->getUser()->hasRole('ROLE_AUTOMARKET_MANAGER') || $this->getUser()->hasRole('ROLE_SUPER_ADMIN')) {
$formMapper
->add('dealer', null, ['label' => 'Дилер', 'required' => false]);
}
$formMapper
->add('model', ModelType::class, ['label' => 'Модель', 'required' => false, 'btn_add' => false])
->add('recommend_group', EntityType::class, [
'class' => RecommendGroup::class,
'label' => 'Входит в подборки',
'multiple' => true,
'required' => false,
])
->add('position', NumberType::class, ['label' => 'Популярность'])
->add('vin', null, ['label' => 'VIN', 'required' => true])
->add('vehicle_items.first.price', NumberType::class, ['label' => 'Цена'])
->add(
'vehicle_items.first.alt_price',
NumberType::class,
['label' => 'Акционная цена', 'required' => false])
->add(
'vehicle_items.first.credit_min_amount',
NumberType::class,
['label' => 'Ежемесячный платеж', 'required' => false]
)
->add('vehicle_items.first.has_nds', CheckboxType::class, ['label' => 'с НДС', 'required' => false])
->add('vehicle_items.first.year', NumberType::class, ['label' => 'Год выпуска'])
->add('vehicle_items.first.mileage', NumberType::class, ['label' => 'Пробег'])
->add('state', CheckboxType::class, ['label' => 'Опубликовать', 'required' => false])
->add(
'credit_available',
CheckboxType::class,
['label' => 'Доступна в кредит', 'required' => false, 'value' => 1]
)
->add('test_drive', CheckboxType::class, ['label' => 'Доступна на тест драйв', 'required' => false])
->add('recommend', CheckboxType::class, ['label' => 'Мы рекомендуем', 'required' => false])
->add('vehicle_items.first.sold', CheckboxType::class, ['label' => 'Продано', 'required' => false])
->add('vehicle_items.first.specify_price', CheckboxType::class, ['label' => 'Уточнить цену', 'required' => false])
->add('vehicle_items.first.deposit', CheckboxType::class, ['label' => 'Внесен задаток', 'required' => false])
->add('vehicle_items.first.is_reserved', CheckboxType::class, ['label' => 'Зарезервировано', 'required' => false])
->add('vehicle_items.first.single_owner', CheckboxType::class, ['label' => 'Один собственник', 'required' => false])
->add(
'vehicle_items.first.service_book',
CheckboxType::class,
['label' => 'Наличие сервисной книги', 'required' => false]
)
->add(
'vehicle_items.first.buy_in_ukraine',
CheckboxType::class,
['label' => 'Куплена в украине', 'required' => false]
)
->add('vehicle_items.first.no_accident', CheckboxType::class, ['label' => 'Без ДТП', 'required' => false])
->add(
'vehicle_items.first.economic_engine',
CheckboxType::class,
['label' => 'Економічний двигун', 'required' => false]
)
->add(
'vehicle_items.first.excellent_technical_condition',
CheckboxType::class,
['label' => 'Відмінний технічний стан', 'required' => false]
)
->add(
'vehicle_items.first.official_service',
CheckboxType::class,
['label' => 'Офіційне сервісне обслуговування', 'required' => false]
)
->add(
'vehicle_items.first.additional_rubber',
CheckboxType::class,
['label' => 'Додатковий комплект гуми', 'required' => false]
)
->add(
'vehicle_items.first.under_warranty',
CheckboxType::class,
['label' => 'Автомобіль на гарантії', 'required' => false]
)
->add(
'vehicle_items.first.top_equipment',
CheckboxType::class,
['label' => 'Топова комплектація', 'required' => false]
)
->add(
'vehicle_items.first.additional_equipment',
CheckboxType::class,
['label' => 'Встановлено додаткове обладнання', 'required' => false]
)
->add(
'vehicle_items.first.official_car',
CheckboxType::class,
['label' => 'Офіційний автомобіль', 'required' => false]
)
// ->add('vehicle_items.first.price_with_PDV', CheckboxType::class, ['label' => 'Ціна з ПДВ', 'required' => false])
->add('vehicle_items.first.best_price', CheckboxType::class, ['label' => 'Найкраща ціна', 'required' => false])
->add('vehicle_items.first.low_mileage', CheckboxType::class, ['label' => 'Низький пробіг', 'required' => false])
->add(
'vehicle_items.first.increased_security',
CheckboxType::class,
['label' => 'Підвищена безпека', 'required' => false]
)
->add('vehicle_items.first.native_color', CheckboxType::class, ['label' => 'Рідна фарба', 'required' => false])
->end()
->end()
->tab('Видео')
->with('', ['class' => 'col-lg12'])
->add('video', ModelListType::class, [
'label' => 'Галерея видео',
'btn_list' => false,
'required' => false,
], [
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
'link_parameters' => [
'context' => 'dc_car_video',
'provider' => 'sonata.media.provider.youtube'
],
'admin_code' => 'sonata.media.admin.gallery',
]
)
->end()
->end()
->tab('Тех. характеристики')
->with('', ['class' => 'col-lg-12'])
->add(
'variations',
CollectionType::class,
[
'label' => false,
'required' => false,
'btn_add' => false,
'btn_catalogue' => false,
'type_options' =>
[
'delete' => false,
'label' => false,
'btn_add' => false,
],
],
[
'by_reference' => false,
'admin_code' => 'admin.vehicles.passenger_variation',
]
)
->end()
->end()
->tab('Опции')
->with('', ['class' => 'col-lg-12'])
->add('vehicle_auto_ria_options', CollectionType::class, [
'by_reference' => false,
'modifiable' => true,
'type_options' => [
'delete' => true,
'btn_add' => false,
'label' => false,
],
], [
'edit' => 'inline',
'inline' => 'table'
])
->end()
->end()
->tab('Особенности')
->with('', ['class' => 'col-lg-6'])
->add('vehicle_items.first.modification', TextType::class, ['label' => 'Модификация', 'required' => false,])
->add('vehicle_items.first.exterior', TextType::class, ['label' => 'Экстерьер', 'required' => false,])
->add(
'vehicle_items.first.interior_ua',
TextType::class,
['label' => 'Интерьер (UA)', 'required' => false,]
)
->add(
'vehicle_items.first.interior_ru',
TextType::class,
['label' => 'Интерьер (RU)', 'required' => false,]
)
->add(
'vehicle_items.first.factory_warranty_ua',
TextType::class,
['label' => 'Заводская гарантия (UA)', 'required' => false,]
)
->add(
'vehicle_items.first.factory_warranty_ru',
TextType::class,
['label' => 'Заводская гарантия (RU)', 'required' => false,]
)
->add(
'vehicle_items.first.approved_warranty_ua',
TextType::class,
['label' => 'Гарантия по программе Approved (UA)', 'required' => false,]
)
->add(
'vehicle_items.first.approved_warranty_ru',
TextType::class,
['label' => 'Гарантия по программе Approved (RU)', 'required' => false,]
)
->add('vehicle_items.first.file', MediaType::class, [
'label' => 'Спецификация',
'provider' => 'sonata.media.provider.file',
'context' => 'dc_file'
])
->add('files', CollectionType::class, [
'label' => 'Акт проверки автомобиля',
'by_reference' => false,
'required' => false,
], [
'edit' => 'inline',
'inline' => 'table',
])
->end()
->end();
}
protected function publish(Vehicle $vehicle): bool
{
$vehicleModel = $this->vehicleFactory
->createByVehicleItem($vehicle->getVehicleItems()->first());
$isPublished = (bool)$vehicle->getRiaId();
$riaId = $vehicle->getRiaId();
$Model = $vehicle->getModel();
$Brand = $Model->getBrand();
$riaBrandId = $Brand->getRiaId();
$riaModelId = $Model->getRiaId();
$riaBrands = $this->autoRia->getBrands();
if (!$riaBrandId) {
foreach ($riaBrands as $rbrand) {
if (trim(strtolower($Brand->getName())) == trim(strtolower($rbrand['title']))) {
$riaBrandId = $rbrand['id'];
break;
}
}
}
$riaModels = null;
if ($riaBrandId) {
$riaModels = $this->autoRia->getModels($riaBrandId);
}
if (!$riaModelId && $riaModels) {
foreach ($riaModels as $rmodel) {
if (trim(strtolower($Model->getTitle())) == trim(strtolower($rmodel['title']))) {
$riaModelId = $rmodel['id'];
break;
}
}
}
$riaBodyId = $this->autoRia->getBodyMap()[$vehicleModel->getBodyType()->getId()];
$riaDriveId = $this->autoRia->getDriveMap()[$vehicleModel->getDriveUnitType()->getId()];
$riaTransId = $this->autoRia->getTransmissionMap()[$vehicleModel->getTransmissionType()->getId()];
$riaFuelId = $this->autoRia->getFuelMap()[$vehicleModel->getFuelType()->getId()];
$capacity = str_replace(' ', '', $vehicleModel->getEngineVolume('ru'));
//TODO remove magic numbers
$capacityUpd = $capacity > 50 ? round(($capacity / 1000), 1) : $capacity;
$capacityUpd = number_format($capacityUpd, 1, '.', ' ');
$doorsCount = $vehicleModel->getDoorsCount('ru');
$seatsCount = $vehicleModel->getSeatsCount()->getValue('ru');
$requestData = [
'damage' => false,
'custom' => false,
'year' => (int)$vehicleModel->getYear(),
'price' => [
'value' => (float)$vehicleModel->price(),
'currency' => [
//TODO remove magic numbers
'id' => 3,
]
],
'categories' => [
'main' => [
//TODO remove magic numbers
'id' => 1,
]
],
'brand' => [
'id' => (int)$riaBrandId
],
'model' => [
'id' => (int)$riaModelId
],
'body' => [
'id' => (int)$riaBodyId
],
//TODO remove magic numbers
'mileage' => $vehicleModel->getMileage() < 1000 ? 1 : floor($vehicleModel->getMileage() / 1000),
'region' => [
'id' => 10
],
'city' => [
'id' => 10
],
'gearbox' => [
'id' => (int)$riaTransId
],
'drive' => [
'id' => (int)$riaDriveId
],
'fuel' => [
'id' => (int)$riaFuelId
],
'engine' => [
'volume' => [
'liters' => (float)$capacityUpd
]
],
'post' => [
'comments' => [
'allowed' => true,
'check' => true,
]
],
"doors" => (int)$doorsCount,
"seats" => (int)$seatsCount,
'spareParts' => false,
];
if ($vehicleModel->getContent('ru')) {
$requestData['description']['ru'] = $vehicleModel->getContent('ru');
}
if ($vehicleModel->getContent('ua')) {
$requestData['description']['uk'] = $vehicleModel->getContent('ua');
}
if ($vehicleModel->getVIN()) {
$requestData['VIN'] = $vehicleModel->getVIN();
$requestData['VIN_open'] = true;
}
$color = $vehicleModel->getBodyColorChar();
$riaColorId = null;
if ($color) {
$colorMap = $this->autoRia->getBodyColorMap();
$riaColorId = $colorMap[$color->getId()] ?? null;
if ($riaColorId) {
$requestData['color'] = [
'id' => (integer)$riaColorId
];
}
}
//TODO remove magic numbers
if (
$isPublished && (!$vehicleModel->getRiaPublicationDate() ||
((time() - $vehicleModel->getRiaPublicationDate()->getTimestamp()) > 60 * 60))
) {
unset($requestData['categories']);
unset($requestData['brand']);
unset($requestData['model']);
unset($requestData['year']);
unset($requestData['custom']);
unset($requestData['gearbox']);
unset($requestData['drive']);
unset($requestData['fuel']);
unset($requestData['doors']);
unset($requestData['VIN']);
}
try {
$result = $this->autoRia->iniByDealer($this->getUser()->getDealer())->addVehicle($requestData, $riaId);
} catch (Exception $exception) {
$this->session
->getFlashBag()
->add('warning', 'AutoRia: ошибка публикации:' . $this->autoRia->getError());
return false;
}
$AutoRiaTxn = new AutoRiaTxn();
$AutoRiaTxn->setDateCreate(new DateTime());
$type = $riaId ? 'update' : 'create';
$AutoRiaTxn->setType($type);
$AutoRiaTxn->setRequest(json_encode($requestData));
if ($result) {
$AutoRiaTxn->setResponse(json_encode($result));
if (!$riaId) {
$riaId = $result->_id;
}
} else {
$AutoRiaTxn->setResponse($this->autoRia->getError());
$this->session
->getFlashBag()
->add(
'warning',
'AutoRia=помилка: ' . $this->autoRia->getError() . ' (або ви у дев режимі то просто ігноруйте)'
);
}
$AutoRiaTxn->setVehicle($vehicle);
$AutoRiaTxn->setUser($this->getUser());
$this->em->persist($AutoRiaTxn);
$this->em->flush();
if (!$result) {
return false;
}
$toSend = [];
if ($vehicle->getAutoRiaOptions()) {
foreach ($vehicle->getAutoRiaOptions()->toArray() as $option){
$toSend[] = ['id' => $option->getAutoRiaId()];
}
$this->autoRia->addOption($toSend, $riaId);
}
if (!$toSend) {
$riaOptions = $vehicle->getRiaOptions();
if ($riaOptions) {
foreach (json_decode($riaOptions) as $id => $title) {
$toSend[] = ['id' => (int)$id];
}
}
}
if ($toSend){
$this->autoRia->addOption($toSend, $riaId);
}
$vehicle->setRiaId($riaId);
if (!$isPublished) {
$this->autoRia->toPublish($riaId, $vehicle->getRiaLevel(), $vehicle->getRiaPeriod(), $isPublished);
$vehicle->setRiaPublicationDate(new DateTime());
$vehicle->setRiaIsNotified(0);
}
return true;
}
/**
* @param ListMapper $listMapper
*/
protected function configureListFields(ListMapper $listMapper): void
{
$user = $this->getUser();
$dealer = $user->getDealer();
$actions = [
'edit' => ['label' => 'Марка'],
'media' => [
'template' => '@AdminBundle/CRUD/list__action_media.html.twig'
],
'delete' => [],
'export' => [
'template' => '@AdminBundle/CRUD/list__action_export_specification.html.twig'
]
];
if ($dealer->getRiaUserId()) {
$actions = array_merge($actions, [
'autoria' => [
'template' => '@AdminBundle/CRUD/list__action_autoria.html.twig'
]
]);
}
$listMapper->addIdentifier('id')
->add('model.brand', null, ['label' => 'Марка'])
->add('model', null, ['label' => 'Модель'])
->add('vin', null, ['label' => 'ВІН'])
->add('adminViews', null, ['label' => 'Перегляди (Всього\День)'])
->add('days', null, ['label' => 'Днів на сайті'])
->add('state', 'choice', ['label' => 'Показувати на сайті', 'editable' => true, 'choices' => [
1 => 'Так',
0 => 'Ні',
]])
->add('is_not_filled', 'choice', ['label' => 'Скоро у продажі', 'editable' => true, 'choices' => [
1 => 'Так',
0 => 'Ніт',
]]);
//TODO remove magic numbers
if ($dealer->getId() == 6) {
$listMapper
->add(
'ria_publication_date',
null,
[
'label' => 'Ria розміщення до',
'template' => '@AdminBundle/CRUD/list__auto_ria_date.html.twig',
'sortable' => false
]
);
}
$listMapper->add('_action', 'actions', [
'label' => 'Дії',
'actions' => $actions,
]);
}
}