Substitute.Controller.js 2.19 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
'use strict'

angular.module('RECRUIT').controller('Substitute', ['$scope', '$http', 'RecService', function($scope, $http, RecService){
   $scope.budesc = {};
   $scope.searchobj = {};
   $scope.emplist = [];

   RecService.ManageRequestForm.query({funcname: 'getBuDesc', reqid: '0'}).$promise.then(function(data){
      $scope.budesc = data.result;
   });

   $scope.search = function(){
      var result = {
         'func': 'substitute',
         'empid': '',
         'positionid': '',
         'bu1id': '',
         'bu2id': '',
         'bu3id': '',
         'bu4id': '',
         'bu5id': ''
      };

      if ($scope.searchobj.empchk == true){
         result.empid = $scope.searchobj.empid;
      }

      if ($scope.searchobj.positionchk == true){
         result.positionid = $scope.searchobj.positionid;
      }

      if ($scope.searchobj.bu1id == true){
         result.bu1id = $scope.searchobj.bu1id;
      }

      if ($scope.searchobj.bu2id == true){
         result.bu2id = $scope.searchobj.bu2id;
      }

      if ($scope.searchobj.bu3id == true){
         result.bu3id = $scope.searchobj.bu3id;
      }

      if ($scope.searchobj.bu4id == true){
         result.bu4id = $scope.searchobj.bu4id;
      }

      if ($scope.searchobj.bu5id == true){
         result.bu5id = $scope.searchobj.bu5id;
      }

      RecService.ManageRequestForm.queryHelp(result).$promise.then(function(data){
         $scope.emplist = data.memployee;
         console.log("DEBUG:: method => search() $scope.emplist =>", $scope.emplist);
      });
   }

   $scope.addObj = function(objstr){
      $scope.searchobj = objstr;
      console.log('DEBUG:: method=> addObj() $scope.searchobj => ', $scope.searchobj);
   }

   $scope.selectAll = function(){
      $scope.emplist.forEach(function(data){
         data.ischeck = true;
      });
   }

   $scope.unSelectAll = function(){
      $scope.emplist.forEach(function(data){
         data.ischeck = false;
      });
   }

   $scope.checkSelect = function(){
      var result = [];

      $scope.emplist.forEach(function(data){
         if (data.ischeck == true){
            result.push(data);
         }
      });

      window.opener.putNewSubstitute(result);
      window.close();
   }
}]);