<commit_before>/*!
 * Copyright 2015 mifort.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

angular.module('mifortTimesheet.employeesReport', ['ngRoute'])

    .config(['$routeProvider', function($routeProvider) {
        $routeProvider.when('/employees-report', {
            templateUrl: 'employeesReport/employeesReport.html',
            controller: 'employeesReportController'
        });
    }])

    .controller('employeesReportController', ['$scope', 'employeesReportService','preferences', 'uiGridConstants', 'topPanelService', '$timeout', '$location',
        function($scope,employeesReportService, preferences, uiGridConstants, topPanelService, $timeout, $location) {
            var companyId = preferences.get('user').companyId,
                userRole = preferences.get('user').role.toLowerCase(),
                headerHeight = 38+12,
                maxVisiblePages = 5,
                columns = employeesReportService.columns;

            $scope.introSteps = employeesReportService.introSteps;

            if(userRole == 'owner' || userRole == 'manager'){
                $scope.userIsManager = true;
            }
            else{
                $scope.userIsManager = false;
            }

            $scope.getAggregatedComments = function(comments) {
                if(comments && comments.length){
                    //remove empty comments
                    var cleanComments = comments.filter(function(e) {
                        return e ? e.replace(/(\r\n|\n|\r)/gm, "") : ""
                    });

                    return cleanComments.join(", ")
                }
            };
            $scope.ranges = {
                'Today': [moment(), moment()],
                //'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 days': [moment().subtract(7, 'days'), moment()],
                'Last 30 days': [moment().subtract(30, 'days'), moment()],
                'This month': [moment().startOf('month'), moment().endOf('month')]
            };

            //default settings, field: "date" value must match the dateRangePicker default value
            $scope.reportSettings = {
                companyId: companyId,
                sort: {
                    field: 'date',
                    asc: false
                },
                filters: [],
                pageSize: 100,
                page: 1,
                groupBy: ['userName'],
                isCommentNeeded: true,
                isreadyForApproveNeeded: true

            };
            $scope.pageRange = $scope.reportSettings.pageSize * ($scope.reportSettings.page - 1) + 1 +"-" +$scope.reportSettings.pageSize * $scope.reportSettings.page;
            if(!$scope.userIsManager){
                $scope.reportSettings.filters.push({<commit_msg>#395 Employees report=> the value of sorting is 100 instead of 10<commit_after>/*!
 * Copyright 2015 mifort.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

angular.module('mifortTimesheet.employeesReport', ['ngRoute'])

    .config(['$routeProvider', function($routeProvider) {
        $routeProvider.when('/employees-report', {
            templateUrl: 'employeesReport/employeesReport.html',
            controller: 'employeesReportController'
        });
    }])

    .controller('employeesReportController', ['$scope', 'employeesReportService','preferences', 'uiGridConstants', 'topPanelService', '$timeout', '$location',
        function($scope,employeesReportService, preferences, uiGridConstants, topPanelService, $timeout, $location) {
            var companyId = preferences.get('user').companyId,
                userRole = preferences.get('user').role.toLowerCase(),
                headerHeight = 38+12,
                maxVisiblePages = 5,
                columns = employeesReportService.columns;

            $scope.introSteps = employeesReportService.introSteps;

            if(userRole == 'owner' || userRole == 'manager'){
                $scope.userIsManager = true;
            }
            else{
                $scope.userIsManager = false;
            }

            $scope.getAggregatedComments = function(comments) {
                if(comments && comments.length){
                    //remove empty comments
                    var cleanComments = comments.filter(function(e) {
                        return e ? e.replace(/(\r\n|\n|\r)/gm, "") : ""
                    });

                    return cleanComments.join(", ")
                }
            };
            $scope.ranges = {
                'Today': [moment(), moment()],
                //'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 days': [moment().subtract(7, 'days'), moment()],
                'Last 30 days': [moment().subtract(30, 'days'), moment()],
                'This month': [moment().startOf('month'), moment().endOf('month')]
            };

            //default settings, field: "date" value must match the dateRangePicker default value
            $scope.reportSettings = {
                companyId: companyId,
                sort: {
                    field: 'date',
                    asc: false
                },
                filters: [],
                pageSize: 10,
                page: 1,
                groupBy: ['userName'],
                isCommentNeeded: true,
                isreadyForApproveNeeded: true

            };
            $scope.pageRange = $scope.reportSettings.pageSize * ($scope.reportSettings.page - 1) + 1 +"-" +$scope.reportSettings.pageSize * $scope.reportSettings.page;
            if(!$scope.userIsManager){
                $scope.reportSettings.filters.push({
{'fraction_non_alphanumeric': 0.12483340737450022, 'fraction_numerical': 0.0090330223604324, 'mean_word_length': 2.0071237756010687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5826671', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1645, 'n_words': 424}