<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity repository-class="App\Entity\PersonnelRepository" name="App\Entity\Personnel"
            table="personnel">
        <id name="id" type="integer" column="id">
            <generator strategy="IDENTITY"/>
        </id>
        <field name="nom" type="string" column="nom" precision="0" scale="0" nullable="false"/>
        <field name="prenom" type="string" column="prenom" precision="0" scale="0" nullable="false"/>
        <field name="fonction" type="string" column="fonction" precision="0" scale="0" nullable="false"/>
        <field name="telinterne" type="string" column="telinterne" precision="0" scale="0" nullable="true"/>
        <field name="telexterne" type="string" column="telexterne" precision="0" scale="0" nullable="true"/>
        <field name="status" type="string" column="status" length="255" precision="0" scale="0" nullable="false"/>
        <field name="emailexterne" type="string" column="emailexterne" precision="0" scale="0" nullable="true"/>
        <field name="dateDernierModif" type="datetime" column="dateDernierModif" precision="0" scale="0"
               nullable="false"/>
        <field name="path" type="string" column="path" length="255" precision="0" scale="0" nullable="true"/>
        <field name="titre" type="string" column="titre" precision="0" scale="0" nullable="true"/>
        <field name="avatar" type="string" column="avatar" precision="0" scale="0" nullable="true"/>
        <field name="username" type="string" column="username" unique="true" nullable="false"/>
        <field name="password" type="string" column="password" unique="false" nullable="false"/>
        <field name="email" column="email" type="string" length="180" />
        <field name="salt" column="salt" type="string" nullable="true" />
        <field name="typeContrat" type="string" column="typeContrat" length="255" precision="0" scale="0" nullable="true"/>
        <field name="nbHeureSemaine" type="string" column="nbHeureSemaine" length="255" precision="0" scale="0" nullable="true"/>
        <field name="datePriseDeFct" type="date" column="datePriseDeFct" length="255" precision="0" scale="0" nullable="true"/>
        <field name="planificationSemaine" type="array" column="planificationSemaine" nullable="true"/>
        <field name="commentaire" type="text" column="commentaire" nullable="true"/>
        <field name="nomContact" type="string" column="nomContact" length="255" precision="0" scale="0" nullable="true"/>
        <field name="adresseContact" type="string" column="adresseContact" length="255" precision="0" scale="0" nullable="true"/>
        <field name="telContact" type="string" column="telContact" length="255" precision="0" scale="0" nullable="true"/>
        <field name="mailContact" type="string" column="mailContact" length="255" precision="0" scale="0" nullable="true"/>
        <field name="pathFichier" type="string" column="pathFichier" length="255" nullable="true"/>
        <field name="fichier" type="text" column="fichier" nullable="true"/>
        <field name="typeCompte" type="string" column="typeCompte" nullable="true"/>
        <field name="restrictionMode" type="text" column="restrictionMode" nullable="true"/>

        <field name="roles" column="roles" type="array" />
        <field name="presence" type="boolean" column="presence" nullable="true"/>
        <field name="receptionDemandes" type="boolean" column="receptionDemandes" nullable="true"/>
        <one-to-many field="servicesGeres" target-entity="App\Entity\Departement" mapped-by="chefService"
                     fetch="LAZY">
            <cascade>
                <cascade-remove/>
            </cascade>
        </one-to-many>
        <many-to-one field="structure" target-entity="App\Entity\Structure" fetch="LAZY">
            <join-columns>
                <join-column name="structure_id" referenced-column-name="id" nullable="true"/>
            </join-columns>
        </many-to-one>
        <many-to-many field="departements" target-entity="App\Entity\Departement" inversed-by="personnels"
                      fetch="LAZY">
            <join-table name="services_personnels">
                <join-columns>
                    <join-column name="personnel_id" referenced-column-name="id" on-delete="CASCADE"/>
                </join-columns>
                <inverse-join-columns>
                    <join-column name="departement_id" referenced-column-name="id" on-delete="CASCADE"/>
                </inverse-join-columns>
            </join-table>
        </many-to-many>
        <many-to-many field="fiches" target-entity="Fiche" mapped-by="agents"/>
        <many-to-many field="questionnaires" target-entity="Questionnaire" mapped-by="agents"/>
        <one-to-many field="demandesCreation" target-entity="Demande" mapped-by="auteur"/>
        <one-to-many field="demandesExecution" target-entity="Demande" mapped-by="executant"/>
        <many-to-many field="demandesAssignee" target-entity="Demande" mapped-by="agents">
        </many-to-many >
        <many-to-many field="departementsFavoris" target-entity="Departement"/>

        <one-to-many field="sessions" target-entity="UserSession" mapped-by="user">
            <cascade>
                <cascade-persist/>
                <cascade-remove/>
            </cascade>
        </one-to-many>

        <one-to-one field="reponse" target-entity="Reponse" mapped-by="agent" nullable="true">
        </one-to-one>

        <one-to-many field="cahiersTransmissionPersonnel" target-entity="CahierTransmissionPersonnel" mapped-by="agent">
            <cascade>
                <cascade-remove/>
            </cascade>
        </one-to-many>

        <one-to-many field="messageDestinataires" target-entity="MessageDestinataire" mapped-by="destinataire">
            <cascade>
                <cascade-remove/>
            </cascade>
        </one-to-many>

        <lifecycle-callbacks>
            <lifecycle-callback type="postPersist" method="upload"/>
            <lifecycle-callback type="postUpdate" method="upload"/>
            <lifecycle-callback type="prePersist" method="preUpload"/>
            <lifecycle-callback type="preUpdate" method="preUpload"/>
            <lifecycle-callback type="preRemove" method="storeFilenameForRemove"/>
            <lifecycle-callback type="postRemove" method="removeUpload"/>
        </lifecycle-callbacks>
    </entity>
</doctrine-mapping>
