var app = angular.module("proj.report")

.service("ReportService", function ($http, $q, ApiCK) {

	return{
		
        obterRelatorioProdutosViews: function (idloja, filtro, page, amount) {

            var d = $q.defer();

            var _url = ("adm/loja/:idloja/reports/produtos/views/filterby/:filtro/:page/:amount")
                .replace(":idloja", idloja)
                .replace(":filtro", filtro)
                .replace(":page", page)               
                .replace(":amount", amount);
            
            var url = ApiCK + _url; 

            console.log(url);

		    $http.get(url)
			.success(function (result) {
			    d.resolve(result);
			})
			.error(function (result) {
			    d.reject(result);
			});

		    return d.promise;
        },

        obterRelatorioProdutosConversoes: function (idloja, filtro, page, amount) {

            var d = $q.defer();

            var _url = ("adm/loja/:idloja/reports/produtos/conversoes/filterby/:filtro/:page/:amount")
                .replace(":idloja", idloja)
                .replace(":filtro", filtro)
                .replace(":page", page)
                .replace(":amount", amount);

            console.log(_url);

            var url = ApiCK + _url;

            $http.get(url)
                .success(function (result) {
                    d.resolve(result);
                })
                .error(function (result) {
                    d.reject(result);
                });

            return d.promise;
        }
	}	
})