'use strict'
angular.module('Training').controller('SurveyList',['$scope', '$http', 'TRE022CONTROL', function($scope, $http, TRE022CONTROL){
   $scope.surveylist = [];
   $scope.myLang = "";
   TRE022CONTROL.surveyData.queryList()
   .$promise.then(function(data){
      $scope.surveylist = data.surveydata;
   })

   $scope.initLang = function($p_lang){
      $scope.myLang = $p_lang;
   }

   $scope.getLabel = function($p_object){
      if ($scope.myLang == 'eng'){
         return $p_object['eng'];
      }else if ($scope.myLang == 'tha'){
         return $p_object['tha'];
      }
   }

   $scope.goPage = function($p_surveyid){
      $scope.elementform = angular.element($("form[name='cscform']"));

      $scope.elementform.attr('action','TRE022_FORM.jsp');
      angular.element($("input[name='__surveyid']").val($p_surveyid));
      document.getElementById('cscform').submit();
   }
}])