'use strict'

angular.module('Empview').controller('Orgchart', ['$scope', '$http', '$mdDialog', 'EmpviewServices', 'SwapLang', function($scope, $http, $mdDialog, EmpviewServices, SwapLang){
  $scope.comdata
  $scope.swlang = SwapLang
  EmpviewServices.RestMcomProfile.getQuery().$promise.then(function(p_data){
    $scope.comdata = p_data.mcom
  })

  $scope.checkPicture = function(p_attac){
    var result = false;
    if (
      p_attac.indexOf('.jpg') > -1 ||
      p_attac.indexOf('.jpeg') > -1 ||
      p_attac.indexOf('.JPG') > -1 ||
      p_attac.indexOf('.JPEG') > -1 ||
      p_attac.indexOf('.png') > -1 ||
      p_attac.indexOf('.PNG') > -1 ||
      p_attac.indexOf('.gif') > -1 ||
      p_attac.indexOf('.GIF') > -1
    ){
      result = true
    }
    return result
  }

  $scope.viewPicture = function(p_attac){

    $mdDialog.show({
      controller: 'PreviewImage',
      templateUrl: 'JS/OI_ORGCHART_NEW/template/dialog.preview.html',
      locals: {images: p_attac},
      clickOutsideToClose: true
    })
  }
}])