(function() {
	'use strict';

	window.app.directive('movementReport', movementReport);
	function movementReport() {
		return {
			scope: { movementData: "=" },
			templateUrl: '/report/template/movementReport.tmpl.cshtml',
			controller: controller,
			controllerAs: 'vm'
		}
	}

	controller.$inject = ['$scope', '$uibModal', 'inventorySvc'];
	function controller($scope, $uibModal, inventorySvc) {
		var vm = this;
		vm.movementData = $scope.movementData;

		vm.editInventory = function (inventoryId) {
			inventorySvc.find(inventoryId)
				.success(function (inventory) {
					$uibModal.open({
						template: '<edit-inventory inventory="inventory" />',
						scope: angular.extend($scope.$new(true), { inventory: inventory })
					});
				});
		}
	}
})();