<?php

namespace KupShop\AutomationConfiguratorBundle\Configurator\Orders\Conditions\Fields;

use KupShop\AutomationConfiguratorBundle\Configurator\Interfaces\Conditions\Fields\Field;
use KupShop\AutomationConfiguratorBundle\Configurator\Orders\OrdersContext;
use KupShop\AutomationConfiguratorBundle\Util\ExpressionContext;

class DayOrderCreated extends Field implements OrdersContext
{
    public function getConfig(): array
    {
        $statuses = [
            ['value' => '1', 'title' => 'Pondělí'],
            ['value' => '2', 'title' => 'Úterý'],
            ['value' => '3', 'title' => 'Středa'],
            ['value' => '4', 'title' => 'Čtvrtek'],
            ['value' => '5', 'title' => 'Pátek'],
            ['value' => '6', 'title' => 'Sobota'],
            ['value' => '0', 'title' => 'Neděle'],
        ];

        return [
            'label' => 'Den vytvoření objednávky',
            'type' => 'multiselect',
            'values' => $statuses,
        ];
    }

    public function getName(): string
    {
        return 'day_created';
    }

    public function getGroupName(): ?string
    {
        return 'time';
    }

    public function getCompareValue(ExpressionContext $context, $args = null)
    {
        $context = $context->getContext();

        return (string) date('w', strtotime($context['o_date_created']));
    }
}
