text: /* ==========================================================================
   * Template: FLK Fullpack Admin Theme
   * ---------------------------------------------------------------------------
   * Author: FLK Payment JS
   * Date : 19/02/2018
   * ========================================================================== */
  
  app.controller('EmploymentTypeController', ['$scope', 'defaultService', 'DTOptionsBuilder', 'DTColumnBuilder', function ($scope, defaultService, DTOptionsBuilder, DTColumnBuilder) {
      $scope.errors = [];
      $scope.EmployeeTypes = [];
  
      $scope.dtOptionsnoBtn = DTOptionsBuilder.newOptions()
          .withDOM('<"html5buttons"B>lTfgitp')
          .withButtons([]);
  
      $scope.dtOptions = DTOptionsBuilder.newOptions()
          .withDOM('<"html5buttons"B>lTfgitp')
          /*.withDisplayLength(15)*/
          .withButtons([
              //{extend: 'copy'},
              {extend: 'csv'},
              {extend: 'excel', title: 'SitePage'},
              {extend: 'pdf', title: 'SitePage'},
  
              {extend: 'print',
                  customize: function (win){
                      $(win.document.body).addClass('white-bg');
                      $(win.document.body).css('font-size', '10px');
  
                      $(win.document.body).find('table')
                          .addClass('compact')
                          .css('font-size', 'inherit');
                  }
              }
          ]);
  
  
      //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      //      Employment Type
      //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
      //---- load Employment Type --- //
      $scope.loadEmploymentType = function(){
          var urlPath = '/' + urlPrefix + 'employee/employment-type/fetch-employment-type';
          defaultService.allGetRequests(urlPath)
              .then(function(resp){
                  $scope.EmploymentTypes = resp.data;
              })
              .then(function(error){
                  if(typeof error != 'undefined'){
                      console.log('An error occurred: ' + JSON.stringify(error));
                  }
              });
  
      }
  
  
      $scope.addEmploymentType = function ($event) {
          $scope.errors = [];
  
          if ($scope.frmemploymenttype.$invalid) {
              swal('Error', 'Please fill all the required fields', 'error');
              return;
          } else {
              $scope.employmenttype.is_deleted = $('#is_deleted').is(':checked');
              var params = $scope.employmenttype;
  
              $event.currentTarget.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Processing...';
              $scope.employmenttype.$invalid = true;
  
              var urlPath = '/' + urlPrefix + 'employee/employment-type';
              defaultService.allPostRequests(urlPath, params)
                  .then(function (resp) {
                      //console.log('Response: ' + JSON.stringify(resp));
                      if (resp.status) {
                          FlicksApp.handlemsgtoast(resp.msg, "success");
                          $scope.errors = [];
                          $('#frmemploymenttype')[0].reset();
                          $("div").removeClass("checked");
                          $scope.frmemploymenttype.$invalid = false;
                      }
                      else {
                          var errors = resp.validation;
                          $scope.errors.push(errors);
                          FlicksApp.handlemsgtoast(resp.msg, "error");
                          $scope.frmemploymenttype.$invalid = false;
                      }
  
                      $event.currentTarget.innerHTML = '<i class="fa fa-save"></i> Add Employment Type';
                  })
                  .then(function (error) {
                      if (typeof error != 'undefined') {
                          $event.currentTarget.innerHTML = '<i class="fa fa-save"></i> Add Employment Type';
                          console.log('An error occurred: ' + JSON.stringify(error));
                      }
                  });
  
          }
      };
  
      $scope.editEmploymentType = function ($event, id) {
          $scope.errors = [];
  
          if ($scope.frmemploymenttype.$invalid) {
              swal('Error', 'Please fill all the required fields', 'error');
              return;
          } else {
              $scope.employmenttype.is_deleted = $('#is_deleted').is(':checked');
              var params = $scope.employmenttype;
  
              $event.currentTarget.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Processing...';
              $scope.frmemploymenttype.$invalid = true;
  
              var urlPath = '/' + urlPrefix + 'employee/employment-type/' + id;
              defaultService.allPutRequests(urlPath, params)
                  .then(function (resp) {
                      //console.log('Response: ' + JSON.stringify(resp));
                      if (resp.status) {
                          FlicksApp.handlemsgtoast(resp.msg, "success");
                          $scope.errors = [];
                          $scope.frmemploymenttype.$invalid = false;
                      }
                      else {
                          var errors = resp.validation;
                          $scope.errors.push(errors);
                          FlicksApp.handlemsgtoast(resp.msg, "error");
                          $scope.frmemploymenttype.$invalid = false;
                      }
  
                      $event.currentTarget.innerHTML = '<i class="fa fa-edit"></i> Edit Employment Type';
                  })
                  .then(function (error) {
                      if (typeof error != 'undefined') {
                          $event.currentTarget.innerHTML = '<i class="fa fa-edit"></i> Edit Employment Type';
                          console.log('An error occurred: ' + JSON.stringify(error));
                      }
                  });
  
          }
      };
  
  }]);