<commit_before><?php

namespace OdpBundle\Entity;

use AppBundle\Entity\Klant;
use AppBundle\Entity\Medewerker;
use AppBundle\Model\KlantRelationInterface;
use AppBundle\Model\RequiredMedewerkerTrait;
use AppBundle\Model\TimestampableTrait;
use AppBundle\Model\UsesKlantTrait;
use AppBundle\Service\KlantDaoInterface;
use AppBundle\Service\NameFormatter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityNotFoundException;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Entity
 * @ORM\Table(name="odp_deelnemers")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="model", type="string")
 * @ORM\DiscriminatorMap({"Huurder" = "Huurder", "Verhuurder" = "Verhuurder"})
 * @ORM\HasLifecycleCallbacks
 * @Gedmo\Loggable
 */
abstract class Deelnemer  implements KlantRelationInterface
{
    use TimestampableTrait, RequiredMedewerkerTrait, UsesKlantTrait;

    /**
     * @var int
     *
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @var Intake
     *
     * @ORM\OneToOne(targetEntity="Intake", mappedBy="deelnemer")
     * @Gedmo\Versioned
     */
    protected $intake;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="aanmelddatum", type="date")
     * @Gedmo\Versioned
     */
    protected $aanmelddatum;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="afsluitdatum", type="date", nullable=true)
     * @Gedmo\Versioned
     */
    protected $afsluitdatum;

    /**
     * @var string
     *
     * @ORM\Column(type="string", nullable=true)
     * @Gedmo\Versioned
     */
    protected $rekeningnummer;

    /**
     * @var bool
     *
     * @ORM\Column(type="boolean", nullable=false)
     * @Gedmo\Versioned
     */
    protected $wpi = false;

    /**
     * @var string
     *
     * @ORM\Column(type="string", nullable=true)
     * @Gedmo\Versioned
     */
    protected $klantmanager;

    /**
     * @var Klant
     *
     * @ORM\OneToOne(targetEntity="AppBundle\Entity\Klant", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false)
     * @Gedmo\Versioned
     */
    protected $klant;

    /**
     * @var ArrayCollection|Verslag[]
     *
     * @ORM\ManyToMany(targetEntity="Verslag", cascade={"persist"})
     * @ORM\JoinTable(name="odp_deelnemer_verslag")
     * @ORM\OrderBy({"datum" = "DESC", "id" = "DESC"})
     */
    protected $verslagen;

    /**
     * @var ArrayCollection|Document[]
     *
     * @ORM\ManyToMany(targetEntity="Document", cascade={"persist"})
     * @ORM\JoinTable(name="odp_deelnemer_document")
     * @ORM\OrderBy({"datum" = "DESC", "id" = "DESC"})
     */
    protected $documenten;

    /**
     * @var Medewerker
     * @ORM\OneToOne(targetEntity="AppBundle\Entity\Medewerker")
     */
    private $ambulantOndersteuner;


    public function __construct()
    {
        $this->aanmelddatum = new \DateTime();

        $this->verslagen = new ArrayCollection();
        $this->documenten = new ArrayCollection();
    }
    /*
     * Dit gaf een exceptie bij koppelingen maken in de view van een huurverzoek. Onderstaande __toString code uit de OekBundle gehaald. Lijkt me prima.
     * @190627 Laat dit even staan voor de zekerheid. jtborger
     */
//    public function __toString()
//    {
//        return (string) $this->klant;
//    }

    public function __toString()
    {
        try {
            return NameFormatter::formatFormal($this->klant);
        } catch (EntityNotFoundException $e) {
            return '';
        }
    }

    public function getId()
    {
        return $this->id;
    }

    public function getKlant()
    {
        return $this->klant;
    }

    public function setKlant(Klant $klant)
    {
        $this->klant = $klant;

        return $this;
    }

    public function getIntake()
    {
        return $this->intake;
    }

    public function getAanmelddatum()
    {
        return $this->aanmelddatum;
    }

    public function setAanmelddatum($aanmelddatum)
    {
        $this->aanmelddatum = $aanmelddatum;

        return $this;
    }

    public function getAfsluitdatum()
    {
        return $this->afsluitdatum;
    }

    public function setAfsluitdatum(\DateTime $afsluitdatum)
    {
        $this->afsluitdatum = $afsluitdatum;

        return $this;
    }

    public function reopen()
    {
        $this->afsluitdatum = null;
        $this->afsluiting = null;

        return $this;
    }

    public function getVerslagen()
    {
        return $this->verslagen;
    }

    public function addVerslag(Verslag $verslag)
    {
        $this->verslagen[] = $verslag;

        return $this;
    }

    public function getDocumenten()
    {
        return $this->documenten;
    }

    public function addDocument(Document $document)
    {
        $this->documenten[] = $document;

        return $this;
    }

    public function getRekeningnummer()
    {
        return $this->rekeningnummer;
    }

    public function setRekeningnummer($rekeningnummer)
    {
        $this->rekeningnummer = $rekeningnummer;

        return $this;
    }

    public function isWpi()
    {
        return (bool) $this->wpi;
    }

    public function setWpi($wpi)
    {
        $this->wpi = $wpi;

        return $this;
    }

    public function getKlantmanager()
    {
        return $this->klantmanager;
    }

    public function setKlantmanager($klantmanager)
    {
        $this->klantmanager = $klantmanager;

        return $this;
    }

    public function getKlantFieldName()
    {
        return "klant";
    }


    /**
     * @return Medewerker
     */
    public function getAmbulantOndersteuner(): ?Medewerker
    {
        return $this->ambulantOndersteuner;
    }

    /**
     * @param Medewerker $ambulantOndersteuner
     */
    public function setAmbulantOndersteuner(?Medewerker $ambulantOndersteuner): void
    {
        $this->ambulantOndersteuner = $ambulantOndersteuner;
    }

    public abstract function getHuurovereenkomsten();

    public function isGekoppeld()
    {
        foreach($this->getHuurovereenkomsten() as $hoe)
        {
            /** @var Huurovereenkomst $hoe */
            $hoe = $hoe;
            if($hoe->isReservering() == false && $hoe->isActief() == true && $hoe->getAfsluitdatum() == null && $hoe->getStartdatum() != null
                && $this->getAfsluitdatum() == null
            )
            {
                return true;
            }
        }
        return false;
    }
}
<commit_msg>Verkeerd soort koppeling waardoor deze uniek werd en dat moest niet.<commit_after><?php

namespace OdpBundle\Entity;

use AppBundle\Entity\Klant;
use AppBundle\Entity\Medewerker;
use AppBundle\Model\KlantRelationInterface;
use AppBundle\Model\RequiredMedewerkerTrait;
use AppBundle\Model\TimestampableTrait;
use AppBundle\Model\UsesKlantTrait;
use AppBundle\Service\KlantDaoInterface;
use AppBundle\Service\NameFormatter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityNotFoundException;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Entity
 * @ORM\Table(name="odp_deelnemers")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="model", type="string")
 * @ORM\DiscriminatorMap({"Huurder" = "Huurder", "Verhuurder" = "Verhuurder"})
 * @ORM\HasLifecycleCallbacks
 * @Gedmo\Loggable
 */
abstract class Deelnemer  implements KlantRelationInterface
{
    use TimestampableTrait, RequiredMedewerkerTrait, UsesKlantTrait;

    /**
     * @var int
     *
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @var Intake
     *
     * @ORM\OneToOne(targetEntity="Intake", mappedBy="deelnemer")
     * @Gedmo\Versioned
     */
    protected $intake;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="aanmelddatum", type="date")
     * @Gedmo\Versioned
     */
    protected $aanmelddatum;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="afsluitdatum", type="date", nullable=true)
     * @Gedmo\Versioned
     */
    protected $afsluitdatum;

    /**
     * @var string
     *
     * @ORM\Column(type="string", nullable=true)
     * @Gedmo\Versioned
     */
    protected $rekeningnummer;

    /**
     * @var bool
     *
     * @ORM\Column(type="boolean", nullable=false)
     * @Gedmo\Versioned
     */
    protected $wpi = false;

    /**
     * @var string
     *
     * @ORM\Column(type="string", nullable=true)
     * @Gedmo\Versioned
     */
    protected $klantmanager;

    /**
     * @var Klant
     *
     * @ORM\OneToOne(targetEntity="AppBundle\Entity\Klant", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false)
     * @Gedmo\Versioned
     */
    protected $klant;

    /**
     * @var ArrayCollection|Verslag[]
     *
     * @ORM\ManyToMany(targetEntity="Verslag", cascade={"persist"})
     * @ORM\JoinTable(name="odp_deelnemer_verslag")
     * @ORM\OrderBy({"datum" = "DESC", "id" = "DESC"})
     */
    protected $verslagen;

    /**
     * @var ArrayCollection|Document[]
     *
     * @ORM\ManyToMany(targetEntity="Document", cascade={"persist"})
     * @ORM\JoinTable(name="odp_deelnemer_document")
     * @ORM\OrderBy({"datum" = "DESC", "id" = "DESC"})
     */
    protected $documenten;

    /**
     * @var Medewerker
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Medewerker")
     * @ORM\JoinColumn(nullable=true)
     */
    private $ambulantOndersteuner;


    public function __construct()
    {
        $this->aanmelddatum = new \DateTime();

        $this->verslagen = new ArrayCollection();
        $this->documenten = new ArrayCollection();
    }
    /*
     * Dit gaf een exceptie bij koppelingen maken in de view van een huurverzoek. Onderstaande __toString code uit de OekBundle gehaald. Lijkt me prima.
     * @190627 Laat dit even staan voor de zekerheid. jtborger
     */
//    public function __toString()
//    {
//        return (string) $this->klant;
//    }

    public function __toString()
    {
        try {
            return NameFormatter::formatFormal($this->klant);
        } catch (EntityNotFoundException $e) {
            return '';
        }
    }

    public function getId()
    {
        return $this->id;
    }

    public function getKlant()
    {
        return $this->klant;
    }

    public function setKlant(Klant $klant)
    {
        $this->klant = $klant;

        return $this;
    }

    public function getIntake()
    {
        return $this->intake;
    }

    public function getAanmelddatum()
    {
        return $this->aanmelddatum;
    }

    public function setAanmelddatum($aanmelddatum)
    {
        $this->aanmelddatum = $aanmelddatum;

        return $this;
    }

    public function getAfsluitdatum()
    {
        return $this->afsluitdatum;
    }

    public function setAfsluitdatum(\DateTime $afsluitdatum)
    {
        $this->afsluitdatum = $afsluitdatum;

        return $this;
    }

    public function reopen()
    {
        $this->afsluitdatum = null;
        $this->afsluiting = null;

        return $this;
    }

    public function getVerslagen()
    {
        return $this->verslagen;
    }

    public function addVerslag(Verslag $verslag)
    {
        $this->verslagen[] = $verslag;

        return $this;
    }

    public function getDocumenten()
    {
        return $this->documenten;
    }

    public function addDocument(Document $document)
    {
        $this->documenten[] = $document;

        return $this;
    }

    public function getRekeningnummer()
    {
        return $this->rekeningnummer;
    }

    public function setRekeningnummer($rekeningnummer)
    {
        $this->rekeningnummer = $rekeningnummer;

        return $this;
    }

    public function isWpi()
    {
        return (bool) $this->wpi;
    }

    public function setWpi($wpi)
    {
        $this->wpi = $wpi;

        return $this;
    }

    public function getKlantmanager()
    {
        return $this->klantmanager;
    }

    public function setKlantmanager($klantmanager)
    {
        $this->klantmanager = $klantmanager;

        return $this;
    }

    public function getKlantFieldName()
    {
        return "klant";
    }


    /**
     * @return Medewerker
     */
    public function getAmbulantOndersteuner(): ?Medewerker
    {
        return $this->ambulantOndersteuner;
    }

    /**
     * @param Medewerker $ambulantOndersteuner
     */
    public function setAmbulantOndersteuner(?Medewerker $ambulantOndersteuner): void
    {
        $this->ambulantOndersteuner = $ambulantOndersteuner;
    }

    public abstract function getHuurovereenkomsten();

    public function isGekoppeld()
    {
        foreach($this->getHuurovereenkomsten() as $hoe)
        {
            /** @var Huurovereenkomst $hoe */
            $hoe = $hoe;
            if($hoe->isReservering() == false && $hoe->isActief() == true && $hoe->getAfsluitdatum() == null && $hoe->getStartdatum() != null
                && $this->getAfsluitdatum() == null
            )
            {
                return true;
            }
        }
        return false;
    }
}

{'fraction_non_alphanumeric': 0.12921604375569737, 'fraction_numerical': 0.0009115770282588879, 'mean_word_length': 2.326174835775644, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7039549', 'n_tokens_mistral': 4558, 'n_tokens_neox': 4350, 'n_words': 749}