'use strict'

angular.module('RECRUIT').controller('BasicConfig', function ($scope, $mdDialog, RecService, $filter, SwapLang) {
  $scope.lang = getLang();
  $scope.HrSwlang = SwapLang
  $scope.basicConfig = {}

  $scope.lstPhoneFormat = [
    {
      "id": "1",
      "regex": "/^0{1}\\d{8,9}$/",
      "format": "0XXXXXXXX / 0XXXXXXXXXX"
    },
    {
      "id": "2",
      "regex": "/^0{1}\\d{1,2}-{1}\\d{3}-{1}\\d{4}$/",
      "format": "0X-XXX-XXXX / 0XX-XXX-XXXX"

    },
    {
      "id": "3",
      "regex": "/^0?\\d{2}[-]?\\d{7}$/",
      "format": "0X-XXXXXXX / 0XX-XXXXXXX"
    }
  ]

  $scope.init = function () {
    RecService.ManageConfig.query({cname: 'BASIC'}).$promise.then(function (data) {
      $scope.basicConfig = data.result
    })
  }
  $scope.init()


  $scope.submit = function () {
    $scope.HrSwlang.getConfirm(1).then(function () {
      RecService.ManageConfig.save($scope.basicConfig).$promise.then(function () {
        $scope.HrSwlang.getAlert(18).then(function () {
          $scope.init()
        })
      }, function () {
        $scope.HrSwlang.getAlert(17)
      })
    })

  };


})