/**
 *
 */
'use strict';
define(function() {
  /**
   * imeiCtrl
   * @param $scope
   * @param $window
   * @param $location
   * @param ApplicationFactory
   * @param RolesFactory
   * @constructor
   */
  var phoneFormInterventionCtrl = function(
    $scope,
    $window,
    $location,
    RolesFactory,
    ngDialog,
    $timeout,
    $filter,
    OdkFactory,
    $http
  ) {
    $scope.newimei = false;

    var refreshList = function() {
      $scope.currentResources = [];

      OdkFactory.getlistintervention().then(
        function(res) {
          /* $scope.testfeature = FeatureTypeFactory.getFeatureByUid('69506c75-9575-4a71-88e1-cb09a48ea263');*/
          $scope.currentResources = res.data;

          //refreshList();
        },
        function(res) {
          require('toastr');
        }
      );
    };

    $scope.removeIntervention = function() {
      OdkFactory.deleteintervention(
        $scope.edit_resource.ID,
        $scope.edit_resource.NAME
      ).then(function(res) {
        /* $scope.testfeature = FeatureTypeFactory.getFeatureByUid('69506c75-9575-4a71-88e1-cb09a48ea263');*/
        //$scope.currentResources = res.data;

        refreshList();
      });
    };
    $scope.editListCfg = {
      dataModule: 'odk',
      resource_type: 'mobileformintervention',
      cols: ['NAME', 'AGENT', 'DATE', 'STATUS'],
      addResourceButton: false,
      hideDetails: true,
      removeFunction: $scope.removeIntervention,
    };

    OdkFactory.getlistintervention().then(function(res) {
      /* $scope.testfeature = FeatureTypeFactory.getFeatureByUid('69506c75-9575-4a71-88e1-cb09a48ea263');*/
      $scope.currentResources = res.data;

      //refreshList();
    });
  };

  phoneFormInterventionCtrl.$inject = [
    '$scope',
    '$window',
    '$location',
    'RolesFactory',
    'ngDialog',
    '$timeout',
    '$filter',
    'OdkFactory',
    '$http',
  ];
  return phoneFormInterventionCtrl;
});
