<?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\FicheRepository" name="App\Entity\Fiche">
    <id name="id" type="integer" column="id">
      <generator strategy="AUTO"/>
    </id>
    <field name="libelle" type="string" column="libelle" length="255" nullable="false"/>
    <field name="derniereExecution" type="datetime" column="derniereExecution" nullable="true"/>
    <field name="heureExecution" type="datetime" column="heureExecution" nullable="false"/>
    <field name="heureDemande" type="datetime" column="heureDemande" nullable="false"/>
    <field name="active" type="boolean" column="active" nullable="false"/>
    <field name="prioriteDemande" type="smallint" column="prioriteDemande" nullable="false"/>
    <field name="heureDebut" type="datetime" column="heureDebut" nullable="false"/>
    <field name="heureFin" type="datetime" column="heureFin" nullable="false"/>
    <field name="dateDebutValidite" type="datetime" column="dateDebutValidite" nullable="false"/>
    <field name="dateFinValidite" type="datetime" column="dateFinValidite" nullable="false"/>
    <field name="remarque" type="text" column="remarque" nullable="true"/>
    <field name="jours" type="simple_array" column="jours" nullable="true"/>


    <many-to-many field="services" target-entity="Departement" inversed-by="fiches">
        <join-table name="fiches_services">
          <join-columns>
            <join-column name="fiche_id" referenced-column-name="id" />
          </join-columns>
          <inverse-join-columns>
            <join-column name="service_id" referenced-column-name="id"/>
          </inverse-join-columns>
      </join-table>
    </many-to-many>

    <one-to-many field="espaces" target-entity="FicheEspace" mapped-by="fiche">
        <cascade>
            <cascade-persist/>
            <cascade-remove/>
        </cascade>
    </one-to-many>

    <many-to-many field="categories" target-entity="Intitule" inversed-by="fiches" fetch="LAZY">
      <join-table name="fiches_intitules">
        <join-columns>
          <join-column name="fiche_id" referenced-column-name="id" />
        </join-columns>
        <inverse-join-columns>
          <join-column name="intitule_id" referenced-column-name="id"/>
        </inverse-join-columns>
      </join-table>
    </many-to-many>

    <many-to-many field="agents" target-entity="Personnel" inversed-by="fiches" fetch="LAZY">
      <join-table name="agents_fiches">
        <join-columns>
          <join-column name="fiche_id" referenced-column-name="id"/>
        </join-columns>
        <inverse-join-columns>
          <join-column name="agent_id" referenced-column-name="id"/>
        </inverse-join-columns>
      </join-table>
    </many-to-many>

  </entity>
</doctrine-mapping>
