angular.module('admin', ['ngRoute', 'menuDirective', 'angularUtils.directives.dirPagination', 'jsMask'])
        .config(function ($routeProvider, $httpProvider) {

            $httpProvider.interceptors.push('tokenInterceptor');

            // login
            $routeProvider.when('/', {
                templateUrl: 'partials/login.html',
                controller: 'LoginController'
            });

            // dashboard
            $routeProvider.when('/dash', {
                templateUrl: 'partials/dash.html',
                controller: 'DashController'
            });


            // faturados
            $routeProvider.when('/invoiced', {
                templateUrl: 'partials/orders/ordersList.html',
                controller: 'InvoicedController'
            });

            // cancelados
            $routeProvider.when('/canceled', {
                templateUrl: 'partials/orders/ordersList.html',
                controller: 'CanceledController'
            });

            // para faturar
            $routeProvider.when('/ready', {
                templateUrl: 'partials/orders/ordersList.html',
                controller: 'ReadyController'
            });


            // pedidos do seller
            $routeProvider.when('/orders', {
                templateUrl: 'partials/orders/ordersList.html',
                controller: 'OrderController'
            });

            // pedido detalhado  add valor de cada item
            $routeProvider.when('/orders/:orderId', {
                templateUrl: 'partials/orders/orderId.html',
                controller: 'OrderIdController'
            });

            //faturar pedido
            $routeProvider.when('/orders/:orderId/invoice', {
                templateUrl: 'partials/orders/invoice.html',
                controller: 'InvoiceOrderController'
            });

            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                // listar itens - ok add coluna com tamanho
                $routeProvider.when('/items', {
                    templateUrl: 'partials/items/itemsListMobile.html',
                    controller: 'StockController'
                });

                // filtros de itens
                $routeProvider.when('/items/:action', {
                    templateUrl: 'partials/items/itemsListMobile.html',
                    controller: 'StockController'
                });
            } else {

                // listar itens - ok add coluna com tamanho
                $routeProvider.when('/items', {
                    templateUrl: 'partials/items/itemsList.html',
                    controller: 'StockController'
                });

                // filtros de itens
                $routeProvider.when('/items/:action', {
                    templateUrl: 'partials/items/itemsList.html',
                    controller: 'StockController'
                });
            }

            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                // alterar estoque
                $routeProvider.when('/items/edit/:ean', {
                    templateUrl: 'partials/items/altStockMobile.html',
                    controller: 'AltStockController'
                });

// alterar estoque por grupo
                $routeProvider.when('/group/edit/:grid', {
                    templateUrl: 'partials/items/gridStockMobile.html',
                    controller: 'GroupStockController'
                });

            } else {


                // cadastrar lojista
                $routeProvider.when('/cadastro/cadastroseller/', {
                    templateUrl: 'partials/items/cadastroseller.html',
                    controller: 'AltSellerController'
                });

                // alterar estoque
                $routeProvider.when('/items/edit/:ean', {
                    templateUrl: 'partials/items/altStock.html',
                    controller: 'AltStockController'
                });

                // alterar estoque por grupo
                $routeProvider.when('/group/edit/:grid', {
                    templateUrl: 'partials/items/gridStock.html',
                    controller: 'GroupStockController'
                });
            }

            //criar promoções
            $routeProvider.when('/promotions', {
                templateUrl: 'partials/promotion/promotionList.html',
                controller: 'ListPromotionController'
            });

            $routeProvider.when('/new/promotions', {
                templateUrl: 'partials/promotion/promotionNew.html',
                controller: 'NewPromotionController'
            });

            $routeProvider.when('/codigodebarras', {
                templateUrl: 'partials/codigobarras.html',
                controller: 'CodigoDeBarrasController'
            });

            $routeProvider.when('/codigodebarrasinserir', {
                templateUrl: 'partials/codigobarrasinserir.html',
                controller: 'CodigoDeBarrasInserirController'
            });

            $routeProvider.when('/codigodebarrasretirar', {
                templateUrl: 'partials/codigobarrasretirar.html',
                controller: 'CodigoDeBarrasRetirarController'
            });


            $routeProvider.otherwise({redirectTo: '/dash'});

        });
