// register common module for shared functionalities for all other feature modules
var commonModule = angular.module('app.common', ['pascalprecht.translate', 'ngAnimate', 'ui.grid', 'ui.grid.selection',
    'ui.grid.treeView', 'ui.grid.resizeColumns', 'mentio', 'app.config'])
    .run(['$log', function ($log) {
        $log.debug('app.common.run()...');
    }])
    // define the script files for lazy loading and method to create depencency map for resovle config in route
    .provider('scriptDependency', ['version', function (version) {
        'use strict';
        // Here must add version parameter ?v=***, 
        // to solve the problem that the bundle is not refreshed when its content changed.

        this.materiallist = [{
            url: '/bundles/materiallist.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/materiallist.css?v=' + version,
            type: 'text/css'
        }];

        this.menu = [{
            url: '/bundles/menu.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/menu.css?v=' + version,
            type: 'text/css'
        }];

        this.commdataimport = [{
            url: '/bundles/commdataimport.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/commdataimport.css?v=' + version,
            type: 'text/css'
        }];

        this.subjectRecategory = [{
            url: '/bundles/subject-recategory.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/subject-recategory.css?v=' + version,
            type: 'text/css'
        }];

        this.role = [{
            url: '/bundles/role.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/role.css?v=' + version,
            type: 'text/css'
        }];

        this.infrastructure = [{
            url: '/bundles/infrastructure.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/infrastructure.less?v=' + version,
            type: 'text/css'
        }];

        this.organization = [{
            url: '/bundles/organization.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/organization.css?v=' + version,
            type: 'text/css'
        }];

        this.project = [{
            url: '/bundles/project.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/project.css?v=' + version,
            type: 'text/css'
        }];

        this.basicDataInfrastructure = [{
            url: '/bundles/basicData.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/basicData.css?v=' + version,
            type: 'text/css'
        }, {
            url: '/bundles/basicData.less?v=' + version,
            type: 'text/css'
        }];

        this.regionManage = [{
            url: '/bundles/regionManage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/regionManage.css?v=' + version,
            type: 'text/css'
        }, {
            url: '/bundles/regionManage.less?v=' + version,
            type: 'text/css'
        }];

        this.keyvalueManage = [{
            url: '/bundles/keyvalueManage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/keyvalueManage.css?v=' + version,
            type: 'text/css'
        }, {
            url: '/bundles/keyvalueManage.less?v=' + version,
            type: 'text/css'
        }];

        this.customerListManage = [{
            url: '/bundles/customerListManage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/customerListManage.css?v=' + version,
            type: 'text/css'
        }, {
            url: '/bundles/customerListManage.less?v=' + version,
            type: 'text/css'
        }];


        this.wordLibraryManage = [{
            url: '/bundles/wordLibraryManage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/wordLibraryManage.css?v=' + version,
            type: 'text/css'
        }, {
            url: '/bundles/wordLibraryManage.less?v=' + version,
            type: 'text/css'
        }];

        this.standardAccountManage = [{
            url: '/bundles/standardAccountManage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/standardAccountManage.css?v=' + version,
            type: 'text/css'
        }, {
            url: '/bundles/standardAccountManage.less?v=' + version,
            type: 'text/css'
        }];

        this.enterpriseAccountManage = [{
            url: '/bundles/enterpriseAccountManage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/enterpriseAccountManage.css?v=' + version,
            type: 'text/css'
        }, {
            url: '/bundles/enterpriseAccountManage.less?v=' + version,
            type: 'text/css'
        }];

        this.systemConfiguration = [{
            url: '/bundles/systemConfiguration.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/systemConfiguration.less?v=' + version,
            type: 'text/css'
        }];

        this.adminHomePage = [{
            url: '/bundles/adminHomePage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/adminHomePage.less?v=' + version,
            type: 'text/css'
        }];


        this.noPermissionPage = [{
            url: '/bundles/noPermissionPage.js?v=' + version,
            type: 'text/javascript'
        }, {
            url: '/bundles/noPermissionPage.less?v=' + version,
            type: 'text/css'
        }];
        
        this.createDependenciesMap = function (dependencies) {
            if (!angular.isArray(dependencies)) {
                throw new TypeError('"scriptUrls" should be an array type!');
            }

            var dependenciesMap = {
                dependency: ['$q', '$rootScope',
                    function ($q, $rootScope) {
                        var deferred = $q.defer();
                        PWC.Loader.load(dependencies, function (hasNewJsLoaded) {
                            // If has new JavaScript resource loaded, should call $apply, otherwise, 
                            // should not call it.
                            if (hasNewJsLoaded) {
                                $rootScope.$apply(function () {
                                    deferred.resolve();
                                });
                            } else {
                                deferred.resolve();
                            }
                        });
                        return deferred.promise;
                    }
                ]
            };

            return dependenciesMap;
        };

        this.$get = function () {
            return {
                worklist: worklist,
                registration: registration,
                report: report,
                clientSetting: clientSetting,
                selfServiceSetting: selfServiceSetting,
                createDependenciesMap: createDependenciesMap,
                menu: menu,
                infrastructure: infrastructure,
                organization: organization,
                project: project,
                basicDataInfrastructure: basicDataInfrastructure,
                regionManage: regionManage,
                keyvalueManage: keyvalueManage,
                wordLibraryManage: wordLibraryManage,
                standardAccountManage: standardAccountManage,
                enterpriceAccountManage: enterpriceAccountManage,
                systemConfiguration: systemConfiguration,
                customerListManage: customerListManage,
                adminHomePage: adminHomePage,
                noPermissionPage: noPermissionPage
            };
        };
    }]);

// register services module
var webservices = angular.module('app.webservices', ['app.common'])
    .run(['$log', function ($log) {
        $log.debug('app.webservices.run()...');
    }]);

// register framework module for application framework
var frameworkModule = angular.module('app.framework', ['app.webservices', 'app.common'])
    .run(['$log', function ($log) {
        $log.debug('app.framework.run()...');
    }]);

// register cache module for application framework
var cacheModule = angular.module('app.cache', ['app.common'])
    .run(['$log', 'cacheService', function ($log, cacheService) {
        $log.debug('app.cache.run()...');

    }]);

//Common Bind Module Method
var bindModule = function (thisModule, controllerProvider, compileProvider, filterProvider, provide) {
    thisModule.controller = controllerProvider.register;
    thisModule.directive = compileProvider.directive;
    thisModule.filter = filterProvider.register;
    thisModule.factory = provide.factory;
    thisModule.service = provide.service;
    return thisModule;
};

//infrastructure module create
var infrastructureModule = angular.module('app.infrastructure', ["isteven-multi-select", 'ui.grid', 'ui.grid.selection', 'ui.grid.selection', 'ui.grid.treeView', 'dx', 'perfect_scrollbar', 'ngMaterial'])
    .run(['$log', function ($log) {
        $log.debug('app.infrastructure.run()...');

    }])
    .config(['$controllerProvider', '$compileProvider', '$filterProvider', '$provide', 'scriptDependencyProvider', '$stateProvider', '$stickyStateProvider',
        function ($controllerProvider, $compileProvider, $filterProvider, $provide, scriptDependencyProvider, $stateProvider, $stickyStateProvider) {
            'use strict';
            // this is required to add controller/directive/filter/service after angular bootstrap
            bindModule(infrastructureModule, $controllerProvider, $compileProvider, $filterProvider, $provide);
            $stateProvider.state({
                name: 'organizationView',
                url: "/organizationViewInfrastructure",
                views: {
                    '@': {
                        controller: ['$scope', '$state',
                            function ($scope, $state) {
                                $scope.state = $state;
                            }],
                        template: '<organization-view-infrastructure state="state"></organization-view-infrastructure>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure)
            });

            //机构管理 覆盖区域
            $stateProvider.state('organizationView.organizationAreaView', {
                url: "/organizationAreaView",
                sticky: true,
                dsr: true,
                params: { "dimensionID": null },
                views: {
                    'organization-area@organizationView': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                     function ($scope, $stateParams, appTranslation) {
                         appTranslation.load([appTranslation.infrastructure, appTranslation.role]);
                     }],
                        template: '<organization-area-view></organization-area-view>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure)
            });

            //机构管理 事业部
            $stateProvider.state('organizationView.organizationBusinessUnitView', {
                url: "/organizationBusinessUnitView",
                sticky: true,
                dsr: true,
                params: {
                    "dimensionID": null
                },
                views: {
                    'organization-businessUnit@organizationView': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                     function ($scope, $stateParams, appTranslation) {
                         appTranslation.load([appTranslation.infrastructure, appTranslation.role]);
                     }],
                        template: '<organization-business-unit-view></organization-business-unit-view>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure)
            });

            //机构管理 子分公司
            $stateProvider.state('organizationView.organizationSubsidiaryView', {
                url: "/organizationSubsidiaryView",
                sticky: true,
                dsr: true,
                params: { "dimensionID": null },
                views: {
                    'organization-subsidiary@organizationView': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                     function ($scope, $stateParams, appTranslation) {
                         appTranslation.load([appTranslation.infrastructure, appTranslation.role]);
                     }],
                        template: '<organization-subsidiary-view></organization-subsidiary-view>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure)
            });

            //股权架构图
            $stateProvider.state('organizationView.storeArchitectureView', {
                url: "/storeArchitectureView",
                sticky: true,
                dsr: true,
                params: { "dimensionID": null },
                views: {
                    'store-architecture@organizationView': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                     function ($scope, $stateParams, appTranslation) {
                         appTranslation.load([appTranslation.infrastructure, appTranslation.role]);
                     }],
                        template: '<store-architecture-view></store-architecture-view>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure)
            });

            //机构管理详细列表
            $stateProvider.state({
                name: 'orgListView',
                url: '/orgListView',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<organization-list-view></organization-list-view>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });



            //用户明细
            $stateProvider.state({
                name: 'userDetail',
                url: '/userDetail/:id',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<user-detail-view></user-detail-view>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'usermanage',
                url: '/usermanage',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                                   function ($scope, $stateParams, appTranslation) {
                                       appTranslation.load([appTranslation.infrastructure]);
                                   }],
                        template: '<user-manage></user-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'user',
                url: '/user',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<user-manage-list></user-manage-list>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });


            $stateProvider.state({
                name: 'userlist',
                url: '/userlist',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<user-list></user-list>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'role',
                url: '/role',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure, appTranslation.role]);
                       }],
                        template: '<role-manage></role-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'fileView',
                url: '/fileView',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                            function ($scope, $stateParams, appTranslation) {
                                appTranslation.load([appTranslation.infrastructure, appTranslation.role]);
                            }],
                        template: '<doc-manage-view></doc-manage-view>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'organization',
                url: '/organization',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<organization-manage></organization-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'organizationSingle',
                url: '/organization/{organizationId}',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                           $scope.organizationId = $stateParams.organizationId;
                       }],
                        template: '<organization-manage organization-id="{{organizationId}}"></organization-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'project',
                url: '/project',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<project-manage></project-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'projectSingle',
                url: '/project/{projectId}/{serviceType}',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                           $scope.projectId = $stateParams.projectId;
                           $scope.serviceType = $stateParams.serviceType;
                       }],
                        template: '<project-manage project-id="{{projectId}}" service-type="{{serviceType}}"></project-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: "menu",
                url: '/menu',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<menu-manage></menu-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });
            $stateProvider.state({
                name: "landManage",
                url: '/landManage',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.infrastructure]);
                       }],
                        template: '<land-manage></land-manage>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.infrastructure),
                deepStateRedirect: true,
                sticky: true
            });

            $stickyStateProvider.enableDebug(true);


        }]);

//basicDataModule module create
var basicDataModule = angular.module('app.basicData', ["isteven-multi-select", 'ui.grid', 'ui.grid.selection', 'ui.grid.selection', 'ui.grid.treeView', 'ui.grid.resizeColumns', 'mc.resizer', 'ngFileSaver'])
    .run(['$log', function ($log) {
        $log.debug('app.basicData.run()...');

    }])
    .config(['$controllerProvider', '$compileProvider', '$filterProvider', '$provide', 'scriptDependencyProvider', '$stateProvider',
        function ($controllerProvider, $compileProvider, $filterProvider, $provide, scriptDependencyProvider, $stateProvider) {
            'use strict';
            // this is required to add controller/directive/filter/service after angular bootstrap
            bindModule(basicDataModule, $controllerProvider, $compileProvider, $filterProvider, $provide);

        }]).config(['$stateProvider', '$urlRouterProvider', 'scriptDependencyProvider', '$stickyStateProvider',
            function ($stateProvider, $urlRouterProvider, scriptDependencyProvider, $stickyStateProvider) {
                'use strict';

                $urlRouterProvider.when('/masterData', '/masterData/orangizationStructureManage');
                $urlRouterProvider.when('/financialData', '/financialData/enterpriseAccountManage');
                //$urlRouterProvider.otherwise('/basicDataInfrastructure/regionManage');

                //主数据
                $stateProvider.state({
                    name: 'masterData',
                    url: "/masterData",
                    views: {
                        '@': {
                            controller: ['$scope', '$state',
                            function ($scope, $state) {
                                $scope.state = $state;
                            }],
                            template: '<basic-data-master-infrastructure state="state"></basic-data-master-infrastructure>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //财务数据
                $stateProvider.state({
                    name: 'financialData',
                    url: "/financialData",
                    views: {
                        '@': {
                            controller: ['$scope', '$state',
                            function ($scope, $state) {
                                $scope.state = $state;
                            }],
                            template: '<basic-data-financial-infrastructure state="state"></basic-data-financial-infrastructure>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //事业部
                $stateProvider.state('masterData.businessUnit', {
                    url: "/businessUnit",
                    sticky: true,
                    dsr: true,
                    views: {
                        'business-unit@masterData': {
                            template: '<business-unit bind="list" attr="{{updateflag}}" add-bs-fn="addbs(newrow)" edit-bs-fn="editbs(newcontent)" remove-bs-fn="removebs(id)" stop-bs-fn="stopbs(newcontent)"></business-unit>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //区域
                $stateProvider.state('masterData.regionManage', {
                    url: "/regionManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'region@masterData': {
                            template: '<region-manage></region-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //关键数据配置
                $stateProvider.state('masterData.keyvalueManage', {
                    url: "/keyvalueManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'key-value@masterData': {
                            template: '<keyvalue-manage></keyvalue-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //字库
                $stateProvider.state('masterData.wordLibraryManage', {
                    url: "/wordLibraryManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'word-library@masterData': {
                            template: '<word-library-manage></word-library-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //机构层级
                $stateProvider.state('masterData.orangizationStructureManage', {
                    url: "/orangizationStructureManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'orangization-structure@masterData': {
                            template: '<orangization-structure-manage bind="list" attr="{{updateflag}}" add-fn="add(newrow)" edit-fn="edit(newcontent)" remove-fn="remove(id)" stop-fn="stop(newcontent)"></orangization-structure-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //客户列表
                $stateProvider.state('financialData.customerListManage', {
                    url: "/customerListManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'customer-list@financialData': {
                            template: '<customer-list-manage ></customer-list-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //标准科目
                $stateProvider.state('financialData.standardAccountManage', {
                    url: "/standardAccountManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'standardAccountManage@financialData': {
                            template: '<standard-account-manage></standard-account-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //企业账套
                $stateProvider.state('financialData.enterpriseAccountManage', {
                    url: "/enterpriseAccountManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'enterprise-account@financialData': {
                            template: '<enterprise-account-manage></enterprise-account-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                //产品清单
                $stateProvider.state('financialData.productManage', {
                    url: "/productManage",
                    sticky: true,
                    dsr: true,
                    views: {
                        'product-manage@financialData': {
                            template: '<product-manage></product-manage>'
                        }
                    },
                    resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.basicDataInfrastructure)
                });

                $stickyStateProvider.enableDebug(true);
            }]);


var systemConfigurationModule = angular.module('app.systemConfiguration', ['ngMessages', 'ngAnimate', 'ui.bootstrap', "isteven-multi-select", 'ui.grid', 'ui.grid.treeView', 'ui.grid.selection', 'dx', 'remoteValidation', 'ui.select', 'ngSanitize'])
    .run(['$log', function ($log) {
        $log.debug('app.systemConfiguration.run()...');
    }])
    .config(['$controllerProvider', '$compileProvider', '$filterProvider', '$provide', 'scriptDependencyProvider', '$stateProvider', '$urlRouterProvider',
        function ($controllerProvider, $compileProvider, $filterProvider, $provide, scriptDependencyProvider, $stateProvider, $urlRouterProvider) {
            'use strict';

            $urlRouterProvider.when('/subjectCorrespondingInfrastructure', '/subjectCorrespondingInfrastructure/enterpriseSubjectCorresponding');
            $urlRouterProvider.when('/ruleEngineConfiguration', '/ruleEngineConfiguration/vatRuleEnginee');
            // this is required to add controller/directive/filter/service after angular bootstrap
            bindModule(systemConfigurationModule, $controllerProvider, $compileProvider, $filterProvider, $provide);

            $stateProvider.state({
                name: 'declarationFormConfiguration',
                url: '/declarationFormConfiguration',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                       }],
                        template: '<declaration-form-configuration></declaration-form-configuration>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'declarationTemplateConfiguration',
                url: '/declarationTemplateConfiguration',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                       }],
                        template: '<declaration-template-configuration></declaration-template-configuration>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'declarationFormConfigurationLocation',
                url: '/declarationFormConfiguration/{templateGroupId}/{templateId}/{cellTemplateId}',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                           $scope.templateGroupId = $stateParams.templateGroupId;
                           $scope.templateId = $stateParams.templateId;
                           $scope.cellTemplateId = $stateParams.cellTemplateId;
                       }],
                        template: '<declaration-form-configuration template-group-id="{{templateGroupId}}" template-id="{{templateId}}" cell-template-id="{{cellTemplateId}}"></declaration-form-configuration>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'subjectCorresponding',
                url: '/subjectCorresponding',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                       }],
                        template: '<subject-corresponding></subject-corresponding>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'modelConfiguration',
                url: '/modelconfiguration',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                       }],
                        template: '<model-configuration></model-configuration>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'modelConfigurationLocation',
                url: '/modelconfiguration/{organizationId}/{selectedModelCode}',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                           $scope.organizationId = $stateParams.organizationId;
                           $scope.selectedModelCode = $stateParams.selectedModelCode;
                       }],
                        template: '<model-configuration organization-id="{{organizationId}}" selected-model-code="{{selectedModelCode}}"></model-configuration>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'keyCodeConfiguration',
                url: '/keyCodeConfiguration',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                       }],
                        template: '<key-value-config></key-value-config>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state({
                name: 'ruleEngineConfiguration',
                url: '/ruleEngineConfiguration',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation','$state',
                       function ($scope, $stateParams, appTranslation, $state) {
                           appTranslation.load([appTranslation.systemConfiguration]);
                           $scope.state = $state;
                       }],
                        template: '<rule-engine-infrastructure state="state"></rule-engine-infrastructure>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration),
                deepStateRedirect: true,
                sticky: true
            });

            $stateProvider.state('ruleEngineConfiguration.vatRuleEnginee', {
                url: "/vatRuleEnginee",
                sticky: true,
                dsr: true,
                views: {
                    'vat-rule@ruleEngineConfiguration': {
                        //template: '<rule-enginee-config></rule-enginee-config>'
                        template: '<rule-engine-config></rule-engine-config>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration)
            });

            $stateProvider.state('ruleEngineConfiguration.fixedAssets', {
                url: "/fixedAssets",
                sticky: true,
                dsr: true,
                views: {
                    'fixed-assets@ruleEngineConfiguration': {
                        //template: '<rule-enginee-config></rule-enginee-config>'
                        template: '<fixed-assets-rule-enginee></fixed-assets-rule-enginee>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.systemConfiguration)
            });
        }]);

var adminHomePageModule = angular.module('app.adminHomePage', ["isteven-multi-select", 'ui.grid', 'ui.grid.treeView', 'ui.grid.selection', 'dx', 'remoteValidation', 'ui.select', 'ngSanitize'])
    .run(['$log', function ($log) {
        $log.debug('app.systemConfiguration.run()...');
    }])
    .config(['$controllerProvider', '$compileProvider', '$filterProvider', '$provide', 'scriptDependencyProvider', '$stateProvider', '$urlRouterProvider',
        function ($controllerProvider, $compileProvider, $filterProvider, $provide, scriptDependencyProvider, $stateProvider, $urlRouterProvider) {
            'use strict';

            bindModule(adminHomePageModule, $controllerProvider, $compileProvider, $filterProvider, $provide);

            $stateProvider.state({
                name: 'adminHomePage',
                url: '/adminHomePage',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.adminHomePage]);
                       }],
                        template: '<admin-home-page></admin-home-page>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.adminHomePage),
                deepStateRedirect: true,
                sticky: true
            });
        }]);


var noPermissionPageModule = angular.module('app.noPermissionPage', ["isteven-multi-select", 'ui.grid', 'ui.grid.treeView', 'ui.grid.selection', 'dx', 'remoteValidation', 'ui.select', 'ngSanitize'])
    .run(['$log', function ($log) {
        $log.debug('app.noPermissionPage.run()...');
    }])
    .config(['$controllerProvider', '$compileProvider', '$filterProvider', '$provide', 'scriptDependencyProvider', '$stateProvider', '$urlRouterProvider',
        function ($controllerProvider, $compileProvider, $filterProvider, $provide, scriptDependencyProvider, $stateProvider, $urlRouterProvider) {
            'use strict';

            // this is required to add controller/directive/filter/service after angular bootstrap
            bindModule(noPermissionPageModule, $controllerProvider, $compileProvider, $filterProvider, $provide);

            $stateProvider.state({
                name: 'noPermissionPage',
                url: '/noPermissionPage',
                views: {
                    '@': {
                        controller: ['$scope', '$stateParams', 'appTranslation',
                       function ($scope, $stateParams, appTranslation) {
                           appTranslation.load([appTranslation.adminHomePage]);
                       }],
                        template: '<no-permission-page></no-permission-page>'
                    }
                },
                resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.noPermissionPage),
                deepStateRedirect: true,
                sticky: true
            });
        }]);