<div ng-controller="ficheCCtrl" class="wrapper" anc-bac-controle-common-logic>
  <controle-form-cfg
    type="currentControle.properties.type"
    ng-if="!ctrl_clos"
    form-data="cdata"
    validation="ctrlCfgValid.values"
  ></controle-form-cfg>
  <div class="mainFormTitle">
    <span>FICHE C > </span>
    Vérification de l’exécution des travaux d’une installation d’assainissement
    non collectif dont la charge brute de pollution organique est inférieure ou
    égale à 1,2 kg/j de DBO5
  </div>

  <div class="mainFormSubTitle condensedInfos">
    <div class="row">
      <div class="col-xs-4">
        <label data-for="cdata.general.date_passage"> Date du passage </label>
      </div>
      <div class="col-xs-8">
        <div
          javautildate
          model-date-format="'no_hours'"
          gcatt="{name:'date_passage'}"
          result="cdata.general"
          ng-init="cdata.general.date_passage = cdata.general.date_passage ?cdata.general.date_passage : {}"
          field-data="{disabled:ctrl_clos}"
          data-ng-model="cdata.general.date_passage"
          data-type="date"
        ></div>
      </div>
    </div>
    <div class="row">
      <div class="col-xs-4">
        <label data-for="cdata.general.statut_rdv"> Statut </label>
      </div>
      <div class="col-xs-8">
        <div class="input-group">
          <select
            class="form-control"
            ng-model="cdata.general.statut_rdv"
            ng-options="statut.value as statut.label for statut in choixStatutRDV"
            ng-disabled="ctrl_clos || !allowChangementAvis"
          ></select>
          <span class="input-group-btn">
            <div
              class="btn btn-default"
              ng-click="unlinkStatut()"
              ng-disabled="!allowChangementAvis || !cdata.general.statut_rdv"
            >
              <i class="fa fa-close"></i>
            </div>
          </span>
        </div>
      </div>
    </div>
    <div
      class="row spbrow"
      ng-if="cdata.general.statut_rdv && cdata.general.statut_rdv!='present' "
    >
      <div class="input-group">
        <div class="col-xs-4">
          <label data-for="cdata.general.origine_du_report_annulation">Origine du report/annulation</label>
        </div>
        <div class="col-xs-8">
          <div class="input-group">
            <div form-field
                 fti="kis_anc_listes_deroulantes_controles"
                 attname="'origine_du_report_annulation'"
                 ng-model="cdata.general.origine_du_report_annulation"
                 res="cdata.general"
                 field-data="{disabled:ctrl_clos}">
            </div>
          </div>
        </div>
      </div>

      <div class="input-group">
        <div class="col-xs-4">
          <label data-for="cdata.general.statut_rdv_commnentaire"> Commentaire </label>
        </div>
        <div class="col-xs-8">
          <textarea class="form-control" ng-model="cdata.general.statut_rdv_commnentaire"></textarea>
        </div>
        <br /><br /><br />
      </div>

      <div class="col-xs-12 text-right">
        <div class="btn btn-danger" ng-click="pre_appliquerAvisControle(1)">
          Appliquer ce statut au contrôle
        </div>
      </div>
    </div>

    <div class="row">
      <div class="col-xs-4">
        <label data-for="cdata.general.reference_spanc">
          Référence SPANC
        </label>
      </div>
      <div class="col-xs-8">
        <div class="input-group">
          <input
            type="text"
            class="form-control"
            ng-model="cdata.general.reference_spanc"
            ng-disabled="ctrl_clos"
          />
          <span class="input-group-btn">
            <div
              class="btn btn-default"
              ng-click="refreshSpancInfo()"
              ng-disabled="ctrl_clos"
            >
              <i class="fa fa-refresh"></i>
            </div>
          </span>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-xs-4">
        <label data-for="cdata.general.date">
          Date du ou des contrôle(s)
        </label>
      </div>
      <div class="col-xs-8">
        <input
          type="text"
          class="form-control"
          ng-model="cdata.general.date"
          ng-disabled="ctrl_clos"
          data-autoclose="true"
          name="date"
          data-type="date"
          bs-datepicker
        />
      </div>
    </div>
    <div class="row">
      <div class="col-xs-4">
        <label data-for="cdata.general.installateur"> Installateur </label>
      </div>
      <div class="col-xs-8">
        <div class="input-group">
          <input
            type="text"
            class="form-control"
            ng-model="cdata.general.installateur.nom"
            disabled
          />
          <span class="input-group-btn">
            <div
              class="btn btn-default"
              title="Chercher une entreprise"
              ng-click="prePickInstallateur('installateur')"
              ng-disabled="ctrl_clos"
            >
              <i class="fa fa-search"></i>
            </div>
          </span>
          <span class="input-group-btn">
            <div
              class="btn btn-default"
              ng-click="ouvrirEntrepriseDialog('2')"
              title="Saisir un installateur"
              ng-disabled="ctrl_clos"
            >
              <i class="fa fa-plus"></i>
            </div>
          </span>
          <span class="input-group-btn">
            <div
              class="btn btn-default"
              ng-click="unlinkEntreprise('installateur')"
              title="Supprimer l'installateur"
              ng-disabled="ctrl_clos || !cdata.general.installateur.nom"
            >
              <i class="fa fa-close"></i>
            </div>
          </span>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-xs-4">
        <label data-for="cdata.general.realise_par">
          Contrôle réalisé par
        </label>
      </div>
      <div class="col-xs-8">
        <input
          type="text"
          class="form-control"
          ng-model="cdata.general.realise_par"
          ng-disabled="ctrl_clos"
        />
      </div>
    </div>
  </div>

  <div class="mainFormSubTitle">
    <span class="hiddenforextract" data-for="cdata.main.cadre">
      Cadre du contrôle
    </span>
    <div class="radio">
      <label>
        <input
          type="radio"
          uncheckable-radio
          name="cadre"
          value="ok"
          ng-model="cdata.main.cadre"
          ng-disabled="ctrl_clos"
        />
        <b data-forvalue="cdata.main.cadre"
          >Vérification de l’exécution suite à un projet de conception</b
        >
      </label>
    </div>
    <div class="radio">
      <label>
        <input
          type="radio"
          uncheckable-radio
          name="cadre"
          value="nok"
          ng-model="cdata.main.cadre"
          ng-disabled="ctrl_clos"
        />
        <b data-forvalue="cdata.main.cadre"
          >Contre-visite suite à demande de modification d’exécution</b
        >
      </label>
    </div>
  </div>

  <div
    class="panel-group"
    data-allow-multiple="true"
    data-start-collapsed="true"
    bs-collapse
  >
    <div class="panel panel-info">
      <div class="panel-heading">
        <a bs-collapse-toggle>
          VOLET 1 Vérification des dispositifs constituant l’installation
        </a>
      </div>
      <div class="panel-collapse" bs-collapse-target>
        <div class="panel-body">
          <ng-include
            src="'js/XG/widgets/ancapp/main/views/controle/Fiche_C/verification_dispositifs.html'"
          />
        </div>
      </div>
    </div>

    <div class="panel panel-info">
      <div class="panel-heading">
        <a bs-collapse-toggle>
          VOLET 2 Conclusion du SPANC sur la conformité des travaux exécutés
        </a>
      </div>
      <div class="panel-collapse" bs-collapse-target>
        <div class="panel-body">
          <div>
            <anc-bac-service-controle
              entreprise-fti="entreprisesFti"
              cdata="cdata"
              apptype="'anc'"
              controle-clos="ctrl_clos"
              label-key="cdata.conformite.service_controle"
            ></anc-bac-service-controle>
          </div>
          <div>
            <anc-avis-controle
              type-controle="currentControle.properties.type"
              cdata="cdata"
              ctrl-clos="ctrl_clos || !allowChangementAvis"
              label-key="'cdata.conformite'"
            ></anc-avis-controle>

            <div class="row avisSpanc" ng-if="!ctrl_clos">
              <div class="col-xs-12 text-center">
                <hr />
                <div class="alert alert-danger" ng-if="incompleteForm()">
                  Un ou plusieurs champ(s) défini(s) comme obligatoire(s) ne
                  sont pas remplis.
                  <br />Merci de parcourir votre formulaire pour les remplir.
                </div>

                <div
                  class="btn btn-primary"
                  ng-disabled="incompleteForm()"
                  ng-hide="!allowChangementAvis"
                  ng-click="pre_appliquerAvisControle()"
                >
                  Valider
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
