(function() {
	"use strict";

	window.app.controller("InventoryListController",
	[
		"$uibModal", "inventorySvc", "downloadSvc",
		function($uibModal, inventorySvc, downloadSvc) {
			var vm = this;

			vm.inventories = inventorySvc.inventories;

			vm.add = function() {
				$uibModal.open({
					template: "<inventory-add />",
					backdrop: "static"
				});
			};

			vm.distribute = function() {
				$uibModal.open({
					template: "<inventory-distribute />",
					backdrop: "static"
				});
			};

			vm.export = function() {
				inventorySvc.exportInventory()
					.success(downloadSvc.success);
			};

			vm.import = function() {
				$uibModal.open({
					template: "<inventory-import />",
					backdrop: "static"
				});
			};
		}
	]);
})();