'use strict'

angular.module('TRN_FOLLOWUP').controller('listfollow', ['$scope', '$http', '$sce', 'ListFollowupCtrl', function($scope, $http, $sce, ListFollowupCtrl){
  $scope.me = $('input[name="me"]').val();
  $scope.page = $('input[name="page"]').val();
  $scope.listfollow = [];

  $scope.myparam = {
    page: $scope.page
  };
  
  ListFollowupCtrl.managelistfollowup.query($scope.myparam).$promise.then(function(data){
    $scope.listfollow = data.listfollowData;
    console.log($scope.listfollow);
    $('.loading-page').css('display', 'none')
  })

  $scope.goPage = function($index){
    $('input[name="apsid"]').val($scope.listfollow[$index].apsid);
    $('input[name="trainingid"]').val($scope.listfollow[$index].trainingid);
    $('input[name="apsassessor"]').val($scope.listfollow[$index].apsassessor);

    $('form[name="cscform"]').attr('target','myform');
    $('form[name="cscform"]').attr('action','TRN_FOLLOWUP_FORM.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();
    }
  }
}]);