Committree.Controller.js 2.18 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 88
'use strict'

angular.module('RECRUIT').controller('Committree', ['$scope', '$http', 'RecService', function($scope, $http, RecService){

   $scope.searchobj ={};
   $scope.budesc = {};
   $scope.emplist = [];

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

   $scope.addObj = function(objstr){
      $scope.searchobj = objstr;
   }

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

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

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

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

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

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

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

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

      RecService.ManageRequestForm.queryHelp(searchlist).$promise.then(function(data){
         $scope.emplist = data.mcommittree;
         console.log('DEBUG:: method -> search() $scope.emplist ->',$scope.emplist);
      });
   }

   $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){
            data.committee_type = '1';
            result.push(data);
         }
      });

      window.opener.putNewCommittree(result);
      window.close();
   }

}]);