TRE021.Controller.js 1.31 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
'use strict'
angular.module('Training').controller('TRE021',['$scope', '$http', 'FormRest', function($scope, $http, FormRest){
   $scope.formList = [];
   $scope.mylang = "";
   $scope.elementform = "";
   FormRest.FormList.query()
   .$promise.then(function(data){
      $scope.formList = data.ObjectiveForm;
   })
   $scope.initLang = function($p_lang){
      $scope.mylang = $p_lang;
   }
   $scope.goPage = function($p_formid){
      $scope.elementform = angular.element($("form[name=cscform]"));

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

   $scope.setForm = function($p_formid, $p_type){
      FormRest.FormList.update({ formid: $p_formid.toString(),formtype: $p_type })
      .$promise.then(function(data){
         if ($p_type == '1' || $p_type == '0'){
            $scope.formList = data.ObjectiveForm;

            if ($scope.mylang == 'eng'){
               alert('update status success');
            }else if ($scope.mylang == 'tha'){
               alert('ทำการเปลี่ยนสถานะแบบสำรวจเสร็จสิ้น');
            }

         }else if ($p_type == 'clone'){
            $scope.goPage(data.formid);
         }
      })
   }
}])