(function () {
    'use strict';

    angular
        .module('app.payroll')
        .factory('aplanoDataService', aplanoDataService);

    aplanoDataService.$inject = ['logger', '$http', 'myAppConfig', '$modal', '$rootScope',
        '$timeout'];
    /* @ngInject */
    function aplanoDataService(logger, $http, myAppConfig, $modal, $rootScope,
        $timeout) {
        var vm = this; // jshint ignore: line
        var config = myAppConfig.getAppConfig();
        vm.isLoggedIn = config.isLoggedIn;

        var baseUrl = config.initConfig.appRoot;

        var service = {
            generaAplanoNomina: generaAplanoNomina,
        };
        return service;

        function generaAplanoNomina(parametros,  baseUrl, route) {
            return $http(
                {   method: 'POST', url: baseUrl + route, data: parametros,
                    //responseType: 'arraybuffer',
                    headers: {
                        'Content-type': 'application/json',
                        'Accept': 'application/text, application/json'
                    }
                })
                .then(generaAplanoNominaComplete)
                .catch(generaAplanoNominaFailed);

            function generaAplanoNominaComplete(response) {
                //console.log('generaAplanoNominaComplete');
                return response;
            }

            function generaAplanoNominaFailed(response) {
                //console.log(response.data.extendedMessage);
                logger.error('Error :' + response.data.errorCode + '. ' +
                    response.data.message + '. ' + response.data.moreInfo);
                return response.data;
            }
        }
    } // aplanoDataService(ajaxService, logger, $http)
})();
