'use strict'
angular.module('APP_BU').controller('ListBu', ['$scope', '$http', 'ListBuCtrl', function($scope, $http, ListBuCtrl){
   $scope.listbu = [];

    function getData(){
      ListBuCtrl.manageListBu.query().$promise.then(function(data){
        $scope.listbu = data.ListBuData;
        $('.loading-page').css('display', 'none')
      })
    }

   $scope.goPage = function($index){

      $('input[name="apsid"]').val($scope.listbu[$index].apsid);
      $('input[name="apsgroup"]').val($scope.listbu[$index].apsgroup);
      $('input[name="subdata"]').val($scope.listbu[$index].subdata);
      $('form[name="cscform"]').attr('target','myform');
      $('form[name="cscform"]').attr('action','APPRAISAL_BU_SENA.jsp');
      var winopen = window.open('','myform','left=150,top=150,width=2000,height=2000,toolbar=no,status=yes,scrollbars=yes,resizable=yes');
      if (winopen){
         $('form[name="cscform"]').submit();
         winopen.focus();
      }
      $.closePage = function(){
         winopen.close();
      }
   }

  $(document).ready(function(){
    var isprocess = $("input[name='__isprocess']").val()

    if(isprocess == "1"){
      setTimeout(function(){
        getData()
      }, 20000);
    }else{
      getData()
    }
  });
}]);