'use strict';

define(function() {
  var DBCtrl = function(
    $scope,
    AncAppFactory,
    ngDialog,
    FeatureTypeFactory,
    EditFactory,
    UsersFactory,
    $timeout
  ) {
    $scope.kis_bac_listes_deroulantes_controles = FeatureTypeFactory.getFeatureByUid(
      'kis_bac_listes_deroulantes_controles'
    );

    $scope.genereEnvoiCourrier = function(type_courrier) {
      $scope.getDocxControle('DB_' + type_courrier + '.docx');
    };

    $scope.num_dau = [];
    $scope.getDau = function() {
      console.log($scope.currentControles);
      console.log('getdau');
      $scope.currentControles.forEach(function(ctrl) {
        if (
          ctrl.properties.type === 'DAU' &&
          ctrl.properties.ref_demande_autorisation_urbanisme != null &&
          ctrl.properties.ref_demande_autorisation_urbanisme != ''
        ) {
          $scope.num_dau.push(
            ctrl.properties.ref_demande_autorisation_urbanisme
          );
        }
      });
    };
  };

  DBCtrl.$inject = [
    '$scope',
    'AncAppFactory',
    'ngDialog',
    'FeatureTypeFactory',
    'EditFactory',
    'UsersFactory',
    '$timeout',
  ];
  return DBCtrl;
});
