<div class="col-xs-12 force-padding full-height">
  <div
    bs-active-pane="tabs.activeTab"
    ng-model="tabs.activeTab"
    ng-show="tabs.length > 1 && !uniqueElement"
    ng-hide="hideList"
    bs-tabs
  >
    <div
      ng-repeat="tab in tabs track by $index"
      title="{{ tab.title | translate }}"
      bs-pane
    ></div>
  </div>

  <div
    ng-show="tabs.activeTab === 0 && !whereFilter"
    class="marginBottom-large"
  >
    <form id="formmodel" ng-submit="startChantierAutomatique()">
      <div class="gcDatatableCrud marginTop nopadding" ng-hide="uniqueElement">
        <div class="row nomargin">
          <div class="col-xs-12 nopadding">
            <save-and-get-template-hpo
              config-name="configName"
              data="currentModel"
              run-return="getReturnedTemplate"
              save-template-html="saveTemplateHtml"
              get-template-html="getTemplateHtml"
              exclude-properties="propertiestoexclude"
            ></save-and-get-template-hpo>

            <button
              class="btn btn-success btn-sm pull-right"
              type="submit"
              ng-disabled="disableAnalyseButton(currentModel)"
            >
              <translate>common.apply</translate>
            </button>
          </div>
        </div>
      </div>

      <div class="row marginTop">
        <div class="col-md-12">
          <div class="row nomargin contenu-hpo">
            <div class="col-xs-12 force-padding">
              <div class="row nomargin add-border">
                <h4
                  ng-click="hideprevision = !hideprevision;"
                  ng-init="hideprevision = false;"
                >
                  <a translate>hpo.model.chantierAutomatique.modelchoice</a>
                </h4>
              </div>
            </div>
            <div class="col-md-12 marginTop" ng-hide="hideprevision">
              <div class="form-group clearfix">
                <div class="col-xs-6 nopaddingLeft">
                  <label class="required"
                    ><translate>model.featuretypes.attributes.name</translate></label
                  >
                  <div class="input-group" ng-if="!disabledAll">
                    <select
                      class="form-control"
                      ng-model="currentModel.info"
                      ng-class="{ 'form-control-info' : disabledAll }"
                      aria-describedby="basic-addon1"
                      ng-change="previsionChanged()"
                      ng-options="opt.properties as opt.properties.NOM_PREVISION for opt in existingModels | orderBy:'properties.NOM_PREVISION'"
                    >
                      <option value="" disabled selected hidden translate
                        >model.featuretypes.actions.choisir</option
                      >
                    </select>
                    <span
                      class="input-group-addon btn btn-md btn-default btn-outline-secondary"
                      ng-click="getExistingprevision()"
                    >
                      <i class="fa fa-refresh"></i>
                    </span>
                  </div>
                </div>
              
                <div class="col-xs-6 nopaddingRight">
                  <label
                    ><translate>hpo.common.commentaire</translate></label
                  >
                  <textarea
                    type="textarea"
                    class="form-control"
                    id="inputalias"
                    placeholder="{{ 'hpo.common.easyget' | translate }}"
                    ng-class="{ 'form-control-info' : disabledAll }"
                    ng-model="currentModel.info.COMMENTAIRE_PREVISION"
                    disabled
                  />
              </div>
            </div>
          </div>

          <div class="row nomargin contenu-hpo" >
            <div class="col-xs-12 force-padding">
              <div class="row nomargin add-border">
                <h4
                  ng-click="hideinformations = !hideinformations;"
                  ng-init="hideinformations = false;"
                >
                  <a translate>hpo.model.chantierAutomatique.infochantier</a>
                </h4>
              </div>
            </div>
            <div class="col-md-12 marginTop" ng-hide="hideinformations">
              <div class="form-group clearfix">
                <div
                  class="alert alert-danger"
                  ng-if=" currentModel && currentModel.namechantierautomatique && existingNames &&
                                        existingNames.indexOf(currentModel.namechantierautomatique) !== -1 "
                >
                  <translate>hpo.multicritere.parameters.nameExist</translate>
                </div>

                <div class="col-xs-6 nopaddingLeft">
                  <label class="required"
                    ><translate
                      >hpo.model.chantierAutomatique.name</translate
                    ></label
                  >

                  <input
                    type="text"
                    class="form-control"
                    ng-model="currentModel.namechantierautomatique"
                    limit="25"
                    required
                  />
                </div>

                <div class="col-xs-6 nopaddingRight">
                  <label
                    ><translate>hpo.common.commentaire</translate></label
                  >
                  <textarea
                    type="textarea"
                    class="form-control"
                    id="inputalias"
                    placeholder="{{ 'hpo.common.easyget' | translate }}"
                    ng-model="currentModel.commentairechantierautomatique"
                  />
                </div>
              </div>
            </div>
          </div>
          <div class="row nomargin contenu-hpo">
            <div class="col-md-6 verticalLine">
              <div class=" nomargin add-border">
                <h4
                  ng-click="hideconstraints = !hideconstraints;"
                  ng-init="hideconstraints = false;"
                >
                  <a translate>hpo.model.chantierAutomatique.constraints.title</a>
                </h4>
              </div>
              <div class="col-md-12 marginTop" ng-hide="hideconstraints">
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.constraints.totalconstructionlinear
                    </translat>
                  </label>

                  <input
                    type="number"
                    class="form-control"
                    ng-model="currentModel.constraints.totalconstructionlinear"
                    limit="25"
                    placeholder="4000"
                    required
                  />
                </div>
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.constraints.minimumlinearpermunicipality
                    </translat>
                  </label>
                  <div
                    ng-drop-zone
                    class="dropzone dropzone-chantier"
                    drop-action="/services/{portalid}/file/uploadProcess"
                    remove-action="/services/{portalid}/file/removeUploaded"
                    process-id="currentModel.constraints.minimumlinearpermunicipality"
                    extension=".csv"
                    dropzone-title="{{ 'ngDropZone.impCsvTitle' | translate }}"
                  ></div>
                </div>
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.constraints.percentageofadditionallinear
                    </translat>
                  </label>

                  <input
                    type="number"
                    class="form-control"
                    ng-model="currentModel.constraints.percentageofadditionallinear"
                    limit="25"
                    placeholder="5%"
                    min="0"
                    max="100"
                    required
                  />
                </div>
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.constraints.defaultgeneratedlinear
                    </translat>
                  </label>

                  <input
                    type="number"
                    class="form-control"
                    ng-model="currentModel.constraints.defaultgeneratedlinear"
                    limit="25"
                    placeholder="500"
                    required
                  />
                </div>
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.constraints.specificConstraints
                    </translat>
                  </label>

                  <div
                  ng-drop-zone
                  class="dropzone dropzone-chantier"
                  drop-action="/services/{portalid}/file/uploadProcess"
                  remove-action="/services/{portalid}/file/removeUploaded"
                  process-id="currentModel.constraints.specificConstraints"
                  extension=".csv"
                  dropzone-title="{{ 'ngDropZone.impCsvTitle' | translate }}"
                  ></div>
                </div>
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.constraints.radiusDisjointed
                    </translat>
                  </label>

                  <input
                    type="number"
                    class="form-control"
                    ng-model="currentModel.constraints.radiusDisjointed"
                    limit="25"
                    placeholder="200"
                    required
                  />
                </div>
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.constraints.thresholdDegradation
                    </translat>
                  </label>

                  <input
                    type="number"
                    class="form-control thresholdDegradation"
                    ng-model="currentModel.constraints.thresholdDegradation"
                    limit="25"
                    step="0.1"
                    placeholder="0.3"
                    required
                  />
                </div>
              </div>

              <div class=" nomargin add-border">
                <h4
                  ng-click="optimizationcriteria = !optimizationcriteria;"
                  ng-init="optimizationcriteria = false;"
                >
                  <a translate>hpo.model.chantierAutomatique.optimizationcriteria.title</a>
                </h4>
              </div>
              <div class="col-md-12" ng-hide="optimizationcriteria">
                <div class="col-md-12">
                  <div class="col-md-6">
                    <input type="checkbox" ng-model="currentModel.optimizationcriteria.forecastbreakagerate" disabled>
                    <label>
                      <translate>
                        hpo.model.chantierAutomatique.optimizationcriteria.forecastbreakagerate
                      </translat>
                    </label>
                  </div>
                  <div class="col-md-6">
                    <input type="checkbox" ng-model="currentModel.optimizationcriteria.lengthofconstruction" disabled>
                    <label>
                      <translate>
                        hpo.model.chantierAutomatique.optimizationcriteria.lengthofconstruction
                      </translat>
                    </label>
                  </div>
                </div>
                <div class="col-md-12">
                  <div class="col-md-6">
                    <input type="checkbox" ng-model="currentModel.optimizationcriteria.proportionoftrack">
                    <label>
                      <translate>
                        hpo.model.chantierAutomatique.optimizationcriteria.proportionoftrack
                      </translat>
                    </label>
                  </div>
                  <div class="col-md-6">
                    <input type="checkbox" ng-model="currentModel.optimizationcriteria.hazardwaterloss">
                    <label>
                      <translate>
                        hpo.model.chantierAutomatique.optimizationcriteria.hazardwaterloss
                      </translat>
                    </label>
                  </div>
                </div>

                <div class="col-md-12">
                  <div class="col-md-6">
                    <input type="checkbox" ng-model="currentModel.optimizationcriteria.hazardtrafic">
                    <label>
                      <translate>
                        hpo.model.chantierAutomatique.optimizationcriteria.hazardtrafic
                      </translat>
                    </label>
                  </div>
                  <div class="col-md-6">
                    <input type="checkbox" ng-model="currentModel.optimizationcriteria.priorconnectionindicator">
                    <label>
                      <translate>
                        hpo.model.chantierAutomatique.optimizationcriteria.priorconnectionindicator
                      </translat>
                    </label>
                  </div>
                </div>

                <div class="col-md-12">
                  <div class="col-md-6">
                    <input type="checkbox" ng-model="currentModel.optimizationcriteria.sensitiveConnections">
                    <label>
                      <translate>
                        hpo.model.chantierAutomatique.optimizationcriteria.sensitiveConnections
                      </translat>
                    </label>
                  </div>
                </div>
              </div>
  
            </div>
            <div class="col-md-6">
              <div class=" nomargin add-border">
                <h4
                  ng-click="hidecriteria = !hidecriteria;"
                  ng-init="hidecriteria = false;"
                >
                  <a translate>hpo.model.chantierAutomatique.criteria.title</a>
                </h4>
              </div>
              <div class="col-md-12 marginTop" ng-hide="hidecriteria">
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.criteria.minimumunitlinearconstruction
                    </translat>
                  </label>

                  <input
                    type="nmber"
                    class="form-control"
                    ng-model="currentModel.criteria.minimumunitlinearconstruction"
                    limit="25"
                    placeholder="250"
                    required
                  />
                </div>
                <div class="col-md-12 nopaddingLeft">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.criteria.maximumitlinearconstruction
                    </translat>
                  </label>

                  <input
                    type="number"
                    class="form-control"
                    ng-model="currentModel.criteria.maximumitlinearconstruction"
                    limit="25"
                    placeholder="500"
                    required
                  />
                </div>
                
                <div class="col-md-12 nopaddingLeft" ng-show="currentModel.optimizationcriteria && 
                                                            currentModel.optimizationcriteria.hazardwaterloss && 
                                                            canaFti && canaFti.attributes.length>0">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.criteria.columnpiezometrynetwork
                    </translat>
                  </label>

                  <select 
                     class="form-control" 
                     ng-model="currentModel.criteria.columnpiezometrynetwork" 
                     ng-options="attribute.name as attribute.alias for attribute in canaFti.attributes"
                     required>
                  </select>
                </div>
                <div class="col-md-12 nopaddingLeft" ng-show="currentModel.optimizationcriteria &&
                                                            currentModel.optimizationcriteria.priorconnectionindicator">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.criteria.Priorityconnectionclasstorenew
                    </translat>
                  </label>


                  <div
                  ng-drop-zone
                  class="dropzone dropzone-chantier"
                  drop-action="/services/{portalid}/file/uploadProcess"
                  remove-action="/services/{portalid}/file/removeUploaded"
                  process-id="currentModel.criteria.Priorityconnectionclasstorenew"
                  extension=".csv"
                  dropzone-title="{{ 'ngDropZone.impCsvTitle' | translate }}"
                  ></div>
                </div>
                <div class="col-md-12 nopaddingLeft" ng-show="currentModel.optimizationcriteria &&
                                                            currentModel.optimizationcriteria.hazardtrafic">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.criteria.trafficquotation
                    </translat>
                  </label>
                  <div
                  ng-drop-zone
                  class="dropzone dropzone-chantier"
                  drop-action="/services/{portalid}/file/uploadProcess"
                  remove-action="/services/{portalid}/file/removeUploaded"
                  process-id="currentModel.criteria.trafficquotation"
                  extension=".csv"
                  dropzone-title="{{ 'ngDropZone.impCsvTitle' | translate }}"
                  ></div>
                </div>
                <div class="col-md-12 nopaddingLeft" ng-show="currentModel.optimizationcriteria &&
                                                            currentModel.optimizationcriteria.hazardtrafic">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.criteria.populationdensity
                    </translat>
                  </label>

                  <input
                    type="text"
                    class="form-control"
                    ng-model="currentModel.criteria.populationdensity"
                    limit="25"
                    placeholder="4000"
                    required
                  />
                </div>
                <div class="col-md-12 nopaddingLeft" ng-show="currentModel.optimizationcriteria &&
                                                    currentModel.optimizationcriteria.sensitiveConnections &&
                                                    connectionsFti && connectionsFti.attributes.length>0"
                                                    >
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.connection.attribute
                    </translat>
                  </label>
                  <select 
                     class="form-control" 
                     ng-model="currentModel.sensitiveConnections.attribute" 
                     ng-options="attribute.name as attribute.alias for attribute in connectionsFti.attributes"
                     ng-change="sensitiveConnectionsAttributeChanged()">
                  </select>
                </div>

                <div class="col-md-12 nopaddingLeft" ng-show="currentModel.optimizationcriteria &&
                                                    currentModel.optimizationcriteria.sensitiveConnections &&
                                                    currentModel.sensitiveConnections.attribute &&
                                                    connectionsValues && connectionsValues.length>0">
                  <label class="required">
                    <translate>
                      hpo.model.chantierAutomatique.connection.modalities
                    </translat>
                  </label>
                  <select class="form-control" ng-model="currentModel.sensitiveConnections.values" multiple ng-options="value for value in connectionsValues">
                  </select>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>

  <div ng-show="tabs.activeTab === 1">
    <div class="col-md-12">
      <div class="correctPositionDataTAble"></div>
      <div
        id="hpoPrepareDataHistorique"
        fti="ftiChantierAutomatique"
        attributes="chantierAutomatiqueAttribute"
        height="{{datatableHeightHistoric}}"
        auto-adjust-height="false"
        table-fill-page="false"
        crud="datatableCalageCrudHpo"
        relationshow="true"
        date-format="'dd MMM yyyy HH:mm'"
        reset-filter-on-toggle="true"
        display-total-number="true"
        dont-show-filter="false"
        hide-crud="false"
        usesweetalert="true"
        translate-attrs="translateFtiAttributes"
        display-total-number="true"
        start-count="10"
        button-edit="buttonEditIcon"
        specialactions="buttonSpecialActions"
        where="whereFilter"
        hide-filter="hideFilter"
        dont-use-guid="true"
        special-query-data="'HpoChantierAutomatique'"
        gcdata-datatable
      ></div>
    </div>
  </div>
</div>
