<?php

namespace AppBundle\Entity\Traits;

use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @Iri("http://schema.org/Generic")
 */
trait ActivityPeriodTrait
{

    /**
     * @var \DateTime
     *
     * @Assert\Date
     */
    #[ORM\Column(type: 'date', nullable: true)]
    #[Groups(['commission', 'commission_list', 'organizationfunction', 'access_details_organizationfunction', 'student_registration_organizationfunction', 'student_registration_guardians', 'accesses_list_organizationfunction', 'adherent_list_organizationfunction', 'personnels_list_organizationfunction', 'ca_list_organizationfunction', 'board_list_organizationfunction', 'organizationresponsability', 'access_details_organizationresponsabilities', 'repair', 'equipmentrepair_list', 'placerepair_list', 'control', 'equipmentcontrol_list', 'placecontrol_list', 'equipment_details_equipmentcontrol', 'donor', 'donor_list', 'access_details_donorsfiltered', 'access_details_organization', 'seizureperiodnotation', 'personactivity', 'rule_personactivityactive', 'commissionmember', 'commission_list_commissionmembers', 'companyperson', 'access_details_companypersonaccesses', 'equipmentloan', 'equipmentrent_list', 'equipmentloan_list', 'accessequipment_grid_equipmentloans', 'access_details_equipmentloans', 'own_student_access_equipmentloans', 'licence_cmf_organizationfunction', 'licence_cmf_personactivity', 'adherent_contact_organizationfunction', 'access_details_personactivityactive', 'networkorganization', 'network_list_network', 'accessintangible', 'educationalprojectintangible', 'student_registration_accessintangibles', 'educationalproject_details_educationalprojectintangibles', 'organization_details_network', 'accessbilling_edit_accessintangibles', 'control_edit', 'repair_edit', 'equipment_list_equipmentloan', 'equipmentmediatheque_list_equipmentloan', 'equipmentcostume_list_equipmentloan', 'organization_function_edit', 'cotisation_responsibles_accesses_organizationfunction', 'equipment_availability_form', 'view_from_manager_create_organizationfunction', 'access_intangible_list', 'online_registration_access_details_organizationfunction', 'organization_params_list_network'])]
    private $startDate;

    /**
     * @var \DateTime
     *
     * @Assert\Date
     */
    #[ORM\Column(type: 'date', nullable: true)]
    #[Groups(['commission', 'commission_list', 'organizationfunction', 'access_details_organizationfunction', 'student_registration_organizationfunction', 'student_registration_guardians', 'accesses_list_organizationfunction', 'adherent_list_organizationfunction', 'personnels_list_organizationfunction', 'ca_list_organizationfunction', 'board_list_organizationfunction', 'organizationresponsability', 'repair', 'equipmentrepair_list', 'placerepair_list', 'control', 'equipmentcontrol_list', 'placecontrol_list', 'equipment_details_equipmentcontrol', 'donor', 'donor_list', 'access_details_donorsfiltered', 'access_details_organization', 'seizureperiodnotation', 'personactivity', 'rule_personactivityactive', 'commissionmember', 'commission_list_commissionmembers', 'companyperson', 'equipmentloan', 'equipmentrent_list', 'equipmentloan_list', 'accessequipment_grid_equipmentloans', 'access_details_equipmentloans', 'own_student_access_equipmentloans', 'licence_cmf_organizationfunction', 'licence_cmf_personactivity', 'adherent_contact_organizationfunction', 'access_details_personactivityactive', 'networkorganization', 'network_list_network', 'accessintangible', 'educationalprojectintangible', 'student_registration_accessintangibles', 'accessbilling_edit_accessintangibles', 'control_edit', 'repair_edit', 'equipment_list_equipmentloan', 'equipmentmediatheque_list_equipmentloan', 'equipmentcostume_list_equipmentloan', 'organization_function_edit', 'cotisation_responsibles_accesses_organizationfunction', 'equipment_availability_form', 'view_from_manager_create_organizationfunction', 'access_intangible_list', 'online_registration_access_details_organizationfunction', 'organization_params_list_network'])]
    private $endDate;

    /**
     * Gets start date
     *
     * @return \DateTime
     */
    public function getStartDate() {
        return $this->startDate ? $this->startDate->format('Y-m-d') : $this->startDate;
    }

    /**
     * Sets start date
     *
     * @param \DateTime $startDate
     * @return $this
     */
    public function setStartDate(\DateTime $startDate = null) {
        if($startDate == null) $startDate = new \DateTime();
        $this->startDate = $startDate;
        return $this;
    }

    /**
     * Gets end date
     *
     * @return \DateTime
     */
    public function getEndDate() {
        return $this->endDate ? $this->endDate->format('Y-m-d') : $this->endDate;
    }

    /**
     * Sets end date
     *
     * @param \DateTime $endDate
     * @return $this
     */
    public function setEndDate(\DateTime $endDate = null) {
        $this->endDate = $endDate;
        return $this;
    }
}
