(function () {
	window.app.factory('reportSvc', reportSvc);

	reportSvc.$inject = ['$http'];
	function reportSvc($http) {
		var distributionData = [];
		var movementData = {};

		var svc = {
			distributionData: distributionData,
			loadDistributionReport: loadDistributionReport,
			movementData: movementData,
			loadMovementData: loadMovementData,
			exportMovementData: exportMovementData
		};

		return svc;

		function loadDistributionReport(query) {
			return $http.post('/Report/Distribution', query)
				.success(function (data) {
					angular.copy(data, distributionData);
				});
		}

		function loadMovementData(query) {
			return $http.post('/Report/Movement', query)
				.success(function (data) {
					angular.copy(data, movementData);
				});
		}

		function exportMovementData(query) {
			return $http.post('/Report/MovementExcel', query, { responseType: 'arraybuffer' });
		}
	}
})();