Index: trunk/grails-app/controllers/InventoryItemDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/InventoryItemDetailedController.groovy	(revision 421)
+++ trunk/grails-app/controllers/InventoryItemDetailedController.groovy	(revision 423)
@@ -7,4 +7,5 @@
     def filterService
     def exportService
+    def inventoryCsvService
     def inventoryItemService
     def inventoryMovementService
@@ -30,4 +31,63 @@
         }
         forward(action: 'search', params: params)
+    }
+
+    /**
+    * Disaply the import view.
+    */
+    def importInventory = {
+    }
+
+    /**
+    * Handle the import save.
+    */
+    def importInventorySave = {
+        def result = inventoryCsvService.importInventory(request)
+
+        if(!result.error) {
+            flash.message = g.message(code: "inventory.import.success")
+            redirect(action:search)
+            return
+        }
+
+        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
+        redirect(action: importInventory)
+    }
+
+    /**
+    * Export a csv template.
+    * NOTE: IE has a 'validating' bug in dev mode that causes the export to take a long time!
+    * This does not appear to be a problem once deployed to Tomcat.
+    */
+    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser'])
+    def exportInventoryTemplate = {
+        response.contentType = ConfigurationHolder.config.grails.mime.types["csv"]
+        response.setHeader("Content-disposition", "attachment; filename=InventoryTemplate.csv")
+        def s = inventoryCsvService.buildInventoryTemplate()
+        render s
+    }
+
+    /**
+    * Export a csv test file.
+    */
+    def exportInventoryExample = {
+        response.contentType = ConfigurationHolder.config.grails.mime.types["csv"]
+        response.setHeader("Content-disposition", "attachment; filename=InventoryExample.csv")
+        def s = inventoryCsvService.buildInventoryExample()
+        render s
+    }
+
+    /**
+    * Export the entire inventory as a csv file.
+    */
+    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser'])
+    def exportInventory = {
+
+        def inventoryItemList = InventoryItem.list()
+
+        response.contentType = ConfigurationHolder.config.grails.mime.types["csv"]
+        response.setHeader("Content-disposition", "attachment; filename=Inventory.csv")
+        def s = inventoryCsvService.buildInventory(inventoryItemList)
+        render s
     }
 
