<?php

namespace PointRetrait\Form;

use PointRetrait\PointRetrait;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Thelia\Form\BaseForm;


/**
 * Class MainForm
 * @package PointRetrait\Form
 */
class MainForm extends BaseForm
{
    /**
     * @inheritDoc
     */
    protected function buildForm()
    {
        $this->formBuilder
            ->add(
                "place_id","integer",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()]
                ])
            ->add(
                "title","text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank(), new Constraints\NotNull()],
                    "label" => $this->translator->trans('Place', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'title']
                ])
            ->add(
                "price","number",
                [
                    "required" => true,
                    "constraints" => [new GreaterThanOrEqual(["value" => 0])],
                    "label" => $this->translator->trans('Withdrawal price', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'price']
                ])
            ->add(
                "minimum_amount","number",
                [
                    "required" => true,
                    "constraints" => [new GreaterThanOrEqual(["value" => 0])],
                    "label" => $this->translator->trans('Minimum amount', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'minimum_amount']
                ])
            ->add("latitude", "number", [
                "label" => $this->translator->trans("Latitude", [], PointRetrait::MESSAGE_DOMAIN),
                "label_attr" => ["for" => "latitude"],
                "required" => false
                ])
            ->add("longitude", "number", [
                "label" => $this->translator->trans("Longitude", [], PointRetrait::MESSAGE_DOMAIN),
                "label_attr" => ["for" => "longitude"],
                "required" => false
                ])
            ->add(
                "active","number",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('Active', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'active']
                ])
            ->add(
                "address1","text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('Address1', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'address1']
                ])
            ->add(
                "address2","text",
                [
                    "required" => false,
                    "label" => $this->translator->trans('Address2', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'address2']
                ])
            ->add(
                "zipcode","text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('Zipcode', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'zipcode']
                ])
            ->add(
                "city","text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('City', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'city']
                ])
            ->add(
                "access_comment","textarea",
                [
                    "required" => false,
                    "label" => $this->translator->trans('Access comment', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'access_comment']
                ]
            );
    }

    /**
     * @inheritDoc
     */
    public function getName()
    {
        return "pdr-place-main-update";
    }
}
