angular.module('ReportModule', ['ngRoute']).
// config(['$locationProvider', function($locationProvider) {
    // $locationProvider.html5Mode(true);
// }]).
controller('ReportController', ['$scope', '$http', '$location', function($scope, $http, $location) {

	$scope.leasing = [];
	$scope.service = [];
	$scope.defaulter = [];

	// use a range of 6 months
	var date = new Date();
	var year = date.getFullYear();
	var firstMonth = year + '-' + (date.getMonth() - 5) + '-01';
	var lastMonth = year + '-' + (date.getMonth() + 1) + '-01';

	function initLeasing() {
		$http.get('../res/php/reports.php?action=getLeasingReport&firstMonth='+(date.getMonth() - 5)+"&lastMonth="+(date.getMonth() + 1)).
		success(function(data) {
			$scope.leasing = data;
		});
	};

	function initDefaulters() {
		$http.get('../res/php/reports.php?action=getServiceReport&firstMonth='+firstMonth+"&lastMonth="+lastMonth).
		success(function(data) {
			$scope.service = data;
		});
	};

	function 
() {
		$http.get('../res/php/reports.php?action=getRentDefaultersReport&selectedMonth='+lastMonth).
		success(function(data) {
			$scope.defaulter = data;
		});
	};

	initLeasing();
	initDefaulters();
	initService();
}]);
initService