ShowPaySlip_DHAS.Controller.js 2.89 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
'use strict'

angular.module('EPAYSLIP').controller('ShowPaySlip', ['$scope', '$http', 'EpayslipCtrl', function($scope, $http, EpayslipCtrl) {
  $scope.headerepay = {};
  $scope.bodyepay = [];
  $scope.footer = {};
  $scope.paramlist = {
    gettype: 'showpayslip',
    prgcode: $('input[name="prgcode"]').val(),
    period: $('input[name="period"]').val(),
    months: $('input[name="months"]').val(),
    years: $('input[name="years"]').val(),
    round: $('input[name="round"]').val(),
    salatype: $('input[name="salatype"]').val(),
    gendate: $('input[name="gendate"]').val(),
    periodseq: $('input[name="periodseq"]').val()
  };
  $scope.alertbox = {
    tha: 'หมายเหตุ บริษัทถือว่าข้อความในเอกสารฉบับนี้เป็นความลับ ห้ามเปิดเผยให้ผู้อื่นทราบโดยเด็ดขาด',
    eng: 'Please use this e-letter as the payroll or other income payment slip. The infomation is confidential. please do not reveal it to anyone.',
    getString: function() {
      if (getLang() == 'tha') {
        return this.tha;
      } else {
        return this.eng;
      }
    }
  }
  if ($('input[name="authen"]').val() == '1') {
    EpayslipCtrl.manageEpaySlip.query($scope.paramlist)
      .$promise.then(function(data) {
        $scope.headerepay = data.header;
        $scope.bodyepay = data.body;
        $scope.generateFooter();
        console.log($scope.headerepay);
      });
  }

  $scope.generateFooter = function() {
    $scope.footer = {
      title: {
        tha: 'เรียน ท่านผู้เกี่ยวข้อง',
        eng: 'To whom it may concern,',
        getString: function() {
          if (getLang() == 'tha') {
            return this.tha;
          } else {
            return this.eng;
          }
        }
      },
      body: {
        tha: 'เอกสารฉบับนี้เป็นเอกสารสำคัญ มีลายเซนต์ผู้มีอำนาจลงนามจากระบบอิเลคทรอนิคส์ ออกโดย บริษัท ดี เอช เอ สยามวาลา จำกัด (สำนักงานใหญ่)',
        eng: 'This is certify that document is electronically issued with the authorized, person\'s signature by ' + $scope.headerepay.mbranch.tdesc + '  The document can be used as a reference for employment status and salary verification.',
        getString: function() {
          if (getLang() == 'tha') {
            return this.tha;
          } else {
            return this.eng;
          }
        }
      }
    };
  }

  $scope.generateDate = function() {
    var nowdate = new Date();
    setCalendarLang(getLang());

    return nowdate.getDate() + " " + getMonthFullName(nowdate.getMonth() + 1) + " " + nowdate.getFullYear();
  }
}]);