[116] | 1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
[392] | 2 | import org.codehaus.groovy.grails.commons.ConfigurationHolder |
---|
[485] | 3 | import com.zeddware.grails.plugins.filterpane.FilterUtils |
---|
| 4 | import org.springframework.web.servlet.support.RequestContextUtils as RCU |
---|
[116] | 5 | |
---|
[298] | 6 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager']) |
---|
[116] | 7 | class InventoryItemDetailedController extends BaseController { |
---|
[156] | 8 | |
---|
| 9 | def filterService |
---|
[392] | 10 | def exportService |
---|
[423] | 11 | def inventoryCsvService |
---|
[225] | 12 | def inventoryItemService |
---|
[485] | 13 | def inventoryItemSearchService |
---|
[225] | 14 | def inventoryMovementService |
---|
[156] | 15 | |
---|
[116] | 16 | // the delete, save and update actions only accept POST requests |
---|
[225] | 17 | static allowedMethods = [delete:'POST', save:'POST', update:'POST', useInventoryItem:'POST'] |
---|
[116] | 18 | |
---|
[298] | 19 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
| 20 | def index = { redirect(action:search, params:params) } |
---|
| 21 | |
---|
[392] | 22 | /** |
---|
| 23 | * Set session.inventoryItemSearchParamsMax |
---|
| 24 | */ |
---|
[298] | 25 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
[392] | 26 | def setSearchParamsMax = { |
---|
| 27 | def max = 1000 |
---|
| 28 | if(params.newMax.isInteger()) { |
---|
| 29 | def i = params.newMax.toInteger() |
---|
| 30 | if(i > 0 && i <= max) |
---|
| 31 | session.inventoryItemSearchParamsMax = params.newMax |
---|
| 32 | if(i > max) |
---|
| 33 | session.inventoryItemSearchParamsMax = max |
---|
| 34 | } |
---|
| 35 | forward(action: 'search', params: params) |
---|
| 36 | } |
---|
| 37 | |
---|
[423] | 38 | /** |
---|
[441] | 39 | * Display the import view. |
---|
[423] | 40 | */ |
---|
| 41 | def importInventory = { |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * Handle the import save. |
---|
| 46 | */ |
---|
| 47 | def importInventorySave = { |
---|
| 48 | def result = inventoryCsvService.importInventory(request) |
---|
| 49 | |
---|
| 50 | if(!result.error) { |
---|
| 51 | flash.message = g.message(code: "inventory.import.success") |
---|
| 52 | redirect(action:search) |
---|
| 53 | return |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 57 | redirect(action: importInventory) |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * Export a csv template. |
---|
| 62 | * NOTE: IE has a 'validating' bug in dev mode that causes the export to take a long time! |
---|
| 63 | * This does not appear to be a problem once deployed to Tomcat. |
---|
| 64 | */ |
---|
[392] | 65 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
[423] | 66 | def exportInventoryTemplate = { |
---|
| 67 | response.contentType = ConfigurationHolder.config.grails.mime.types["csv"] |
---|
| 68 | response.setHeader("Content-disposition", "attachment; filename=InventoryTemplate.csv") |
---|
| 69 | def s = inventoryCsvService.buildInventoryTemplate() |
---|
| 70 | render s |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * Export a csv test file. |
---|
| 75 | */ |
---|
| 76 | def exportInventoryExample = { |
---|
| 77 | response.contentType = ConfigurationHolder.config.grails.mime.types["csv"] |
---|
| 78 | response.setHeader("Content-disposition", "attachment; filename=InventoryExample.csv") |
---|
| 79 | def s = inventoryCsvService.buildInventoryExample() |
---|
| 80 | render s |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | /** |
---|
| 84 | * Export the entire inventory as a csv file. |
---|
| 85 | */ |
---|
| 86 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
| 87 | def exportInventory = { |
---|
| 88 | |
---|
| 89 | def inventoryItemList = InventoryItem.list() |
---|
| 90 | |
---|
| 91 | response.contentType = ConfigurationHolder.config.grails.mime.types["csv"] |
---|
| 92 | response.setHeader("Content-disposition", "attachment; filename=Inventory.csv") |
---|
| 93 | def s = inventoryCsvService.buildInventory(inventoryItemList) |
---|
| 94 | render s |
---|
| 95 | } |
---|
| 96 | |
---|
[441] | 97 | /** |
---|
| 98 | * Display the import view for purchases. |
---|
| 99 | */ |
---|
| 100 | def importInventoryItemPurchases = { |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | /** |
---|
| 104 | * Handle the inventory purchases import save. |
---|
| 105 | */ |
---|
| 106 | def importInventoryItemPurchasesSave = { |
---|
| 107 | def result = inventoryCsvService.importInventoryItemPurchases(request) |
---|
| 108 | |
---|
| 109 | if(!result.error) { |
---|
| 110 | flash.message = g.message(code: "inventory.import.success") |
---|
| 111 | redirect(action:search) |
---|
| 112 | return |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 116 | redirect(action: importInventoryItemPurchases) |
---|
| 117 | } |
---|
| 118 | |
---|
[485] | 119 | /** |
---|
| 120 | * Search for Inventory items. |
---|
| 121 | */ |
---|
[423] | 122 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
[139] | 123 | def search = { |
---|
[392] | 124 | |
---|
| 125 | if(session.inventoryItemSearchParamsMax) |
---|
| 126 | params.max = session.inventoryItemSearchParamsMax |
---|
| 127 | |
---|
[485] | 128 | // Protect filterPane. |
---|
| 129 | params.max = Math.min( params.max ? params.max.toInteger() : 10, 1000) |
---|
[156] | 130 | |
---|
[392] | 131 | def inventoryItemInstanceList = [] |
---|
| 132 | def inventoryItemInstanceTotal |
---|
[485] | 133 | def filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) |
---|
| 134 | def isFilterApplied = FilterUtils.isFilterApplied(params) |
---|
[392] | 135 | |
---|
[485] | 136 | // Restore search unless a new search is being requested. |
---|
| 137 | if(!params.quickSearch && !filterParams) { |
---|
[489] | 138 | if(session.inventoryItemQuickSearch) { |
---|
[485] | 139 | params.quickSearch = session.inventoryItemQuickSearch |
---|
[489] | 140 | if(session.inventoryItemQuickSearchDaysBack) |
---|
| 141 | params.daysBack = session.inventoryItemQuickSearchDaysBack.toString() |
---|
| 142 | } |
---|
[485] | 143 | else if(session.inventoryItemSearchFilterParams) { |
---|
| 144 | session.inventoryItemSearchFilterParams.each() { params[it.key] = it.value } |
---|
| 145 | params.filter = session.inventoryItemSearchFilter |
---|
| 146 | isFilterApplied = FilterUtils.isFilterApplied(params) |
---|
| 147 | } |
---|
[156] | 148 | } |
---|
[485] | 149 | |
---|
| 150 | // Remember sort if supplied, otherwise try to restore. |
---|
| 151 | if(params.sort && params.order) { |
---|
| 152 | session.inventoryItemSearchSort = params.sort |
---|
| 153 | session.inventoryItemSearchOrder = params.order |
---|
| 154 | } |
---|
| 155 | else if(session.inventoryItemSearchSort && session.inventoryItemSearchOrder) { |
---|
| 156 | params.sort = session.inventoryItemSearchSort |
---|
| 157 | params.order = session.inventoryItemSearchOrder |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | if(isFilterApplied) { |
---|
| 161 | // filterPane: |
---|
[392] | 162 | inventoryItemInstanceList = filterService.filter( params, InventoryItem ) |
---|
| 163 | inventoryItemInstanceTotal = filterService.count( params, InventoryItem ) |
---|
| 164 | filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) |
---|
[485] | 165 | // Remember search. |
---|
| 166 | session.inventoryItemSearchFilterParams = new LinkedHashMap(filterParams) |
---|
| 167 | session.inventoryItemSearchFilter = new LinkedHashMap(params.filter) |
---|
[489] | 168 | session.removeAttribute("inventoryItemQuickSearch") |
---|
| 169 | session.removeAttribute("inventoryItemQuickSearchDaysBack") |
---|
[392] | 170 | } |
---|
[485] | 171 | else { |
---|
| 172 | // Quick Search: |
---|
| 173 | if(!params.quickSearch) params.quickSearch = "all" |
---|
| 174 | def result = inventoryItemSearchService.getQuickSearch(params, RCU.getLocale(request)) |
---|
| 175 | inventoryItemInstanceList = result.inventoryItemList |
---|
| 176 | inventoryItemInstanceTotal = result.inventoryItemList.totalCount |
---|
| 177 | params.message = result.message |
---|
| 178 | filterParams.quickSearch = result.quickSearch |
---|
| 179 | // Remember search. |
---|
[489] | 180 | session.removeAttribute("inventoryItemSearchFilterParams") |
---|
| 181 | session.removeAttribute("inventoryItemSearchFilter") |
---|
[485] | 182 | session.inventoryItemQuickSearch = result.quickSearch |
---|
[489] | 183 | if(result.daysBack) |
---|
| 184 | session.inventoryItemQuickSearchDaysBack = result.daysBack |
---|
[485] | 185 | } |
---|
[139] | 186 | |
---|
[392] | 187 | // export plugin: |
---|
| 188 | if(params?.format && params.format != "html") { |
---|
| 189 | |
---|
| 190 | def dateFmt = { date -> |
---|
| 191 | formatDate(format: "EEE, dd-MMM-yyyy", date: date) |
---|
| 192 | } |
---|
| 193 | |
---|
[485] | 194 | String title |
---|
| 195 | if(params.quickSearch) |
---|
| 196 | title = params.message |
---|
| 197 | else |
---|
| 198 | title = "Filtered Inventory List." |
---|
| 199 | |
---|
[392] | 200 | response.contentType = ConfigurationHolder.config.grails.mime.types[params.format] |
---|
| 201 | response.setHeader("Content-disposition", "attachment; filename=Inventory.${params.extension}") |
---|
| 202 | List fields = ["name", |
---|
| 203 | "description", |
---|
| 204 | "unitsInStock", |
---|
[485] | 205 | "reorderPoint", |
---|
[392] | 206 | "unitOfMeasure", |
---|
| 207 | "inventoryLocation", |
---|
| 208 | "inventoryLocation.inventoryStore"] |
---|
| 209 | Map labels = ["name": "Name", |
---|
| 210 | "description": "Description", |
---|
| 211 | "unitsInStock":"In Stock", |
---|
[485] | 212 | "reorderPoint":"Reorder Point", |
---|
[392] | 213 | "unitOfMeasure": "UOM", |
---|
| 214 | "inventoryLocation": "Location", |
---|
| 215 | "inventoryLocation.inventoryStore": "Store"] |
---|
| 216 | |
---|
| 217 | Map formatters = [:] |
---|
| 218 | Map parameters = [title: title, separator: ","] |
---|
| 219 | |
---|
| 220 | exportService.export(params.format, |
---|
| 221 | response.outputStream, |
---|
| 222 | inventoryItemInstanceList.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }, |
---|
| 223 | fields, |
---|
| 224 | labels, |
---|
| 225 | formatters, |
---|
| 226 | parameters) |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | // Add some basic params to filterParams. |
---|
| 230 | filterParams.max = params.max |
---|
| 231 | filterParams.offset = params.offset?.toInteger() ?: 0 |
---|
[485] | 232 | filterParams.sort = params.sort ?: "name" |
---|
| 233 | filterParams.order = params.order ?: "asc" |
---|
[392] | 234 | |
---|
| 235 | return[ inventoryItemInstanceList: inventoryItemInstanceList, |
---|
| 236 | inventoryItemInstanceTotal: inventoryItemInstanceTotal, |
---|
[485] | 237 | filterParams: filterParams, |
---|
| 238 | params: params ] |
---|
[392] | 239 | } // end search() |
---|
| 240 | |
---|
[225] | 241 | /** |
---|
| 242 | * Simply assigns a passed in task id to a session variable and redirects to search. |
---|
| 243 | */ |
---|
[298] | 244 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
[225] | 245 | def findInventoryItemForMovement = { |
---|
| 246 | if(!params.task?.id) { |
---|
| 247 | flash.message = "No task id supplied, please select a task then the inventory tab." |
---|
| 248 | redirect(controller: "taskDetailed", action: "search") |
---|
| 249 | return |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | session.inventoryMovementTaskId = params.task.id |
---|
| 253 | flash.message = "Please find and then select the inventory item." |
---|
| 254 | redirect(action: search) |
---|
| 255 | } |
---|
| 256 | |
---|
[298] | 257 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
[116] | 258 | def show = { |
---|
[225] | 259 | |
---|
[139] | 260 | // In the case of an actionSubmit button, rewrite action name from 'index'. |
---|
| 261 | if(params._action_Show) |
---|
[375] | 262 | params.action='show' |
---|
[116] | 263 | |
---|
[405] | 264 | def result = inventoryItemService.show(params) |
---|
[225] | 265 | |
---|
[405] | 266 | if(!result.error) { |
---|
[225] | 267 | |
---|
[405] | 268 | def model = [ inventoryItemInstance: result.inventoryItemInstance, |
---|
| 269 | inventoryMovementList: result.inventoryMovementList, |
---|
| 270 | inventoryMovementListTotal: result.inventoryMovementListTotal, |
---|
| 271 | inventoryMovementListMax: result.inventoryMovementListMax, |
---|
[441] | 272 | inventoryItemPurchases: result.inventoryItemPurchases, |
---|
| 273 | inventoryItemPurchasesTotal: result.inventoryItemPurchasesTotal, |
---|
[405] | 274 | showTab: result.showTab] |
---|
[225] | 275 | |
---|
[405] | 276 | if(session.inventoryMovementTaskId) { |
---|
| 277 | model.inventoryMovementInstance = new InventoryMovement() |
---|
| 278 | model.inventoryMovementInstance.task = Task.get(session.inventoryMovementTaskId) |
---|
| 279 | model.inventoryMovementInstance.quantity = 1 |
---|
| 280 | } |
---|
[225] | 281 | |
---|
[405] | 282 | // Success. |
---|
| 283 | return model |
---|
[225] | 284 | } |
---|
| 285 | |
---|
[405] | 286 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 287 | redirect(action:search) |
---|
[116] | 288 | } |
---|
| 289 | |
---|
| 290 | def delete = { |
---|
[405] | 291 | def result = inventoryItemService.delete(params) |
---|
| 292 | |
---|
| 293 | if(!result.error) { |
---|
| 294 | flash.message = g.message(code: "default.delete.success", args: ["InventoryItem", params.id]) |
---|
[408] | 295 | redirect(action:search) |
---|
[405] | 296 | return |
---|
[116] | 297 | } |
---|
[405] | 298 | |
---|
| 299 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 300 | |
---|
| 301 | if(result.error.code == "default.not.found") { |
---|
[139] | 302 | redirect(action:search) |
---|
[405] | 303 | return |
---|
[116] | 304 | } |
---|
[405] | 305 | |
---|
| 306 | redirect(action:show, id: params.id) |
---|
[116] | 307 | } |
---|
| 308 | |
---|
| 309 | def edit = { |
---|
[375] | 310 | |
---|
[139] | 311 | // In the case of an actionSubmit button, rewrite action name from 'index'. |
---|
| 312 | if(params._action_Edit) |
---|
[375] | 313 | params.action='edit' |
---|
| 314 | |
---|
[405] | 315 | def result = inventoryItemService.edit(params) |
---|
[116] | 316 | |
---|
[425] | 317 | if(!result.error) { |
---|
| 318 | def possibleAlternateItems = inventoryItemService.getPossibleAlternateItems(result.inventoryItemInstance) |
---|
[435] | 319 | def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
| 320 | def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
| 321 | |
---|
| 322 | return [ inventoryItemInstance : result.inventoryItemInstance, |
---|
| 323 | possibleAlternateItems: possibleAlternateItems, |
---|
| 324 | suppliers: suppliers, |
---|
| 325 | manufacturers: manufacturers] |
---|
[425] | 326 | } |
---|
[405] | 327 | |
---|
| 328 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 329 | redirect(action:search) |
---|
[116] | 330 | } |
---|
| 331 | |
---|
| 332 | def update = { |
---|
[405] | 333 | def result = inventoryItemService.update(params) |
---|
| 334 | |
---|
| 335 | if(!result.error) { |
---|
| 336 | flash.message = g.message(code: "default.update.success", args: ["InventoryItem", params.id]) |
---|
| 337 | redirect(action:show, id: params.id) |
---|
| 338 | return |
---|
[116] | 339 | } |
---|
[405] | 340 | |
---|
| 341 | if(result.error.code == "default.not.found") { |
---|
| 342 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
[175] | 343 | redirect(action:search) |
---|
[405] | 344 | return |
---|
[116] | 345 | } |
---|
[405] | 346 | |
---|
[425] | 347 | def possibleAlternateItems = inventoryItemService.getPossibleAlternateItems(result.inventoryItemInstance) |
---|
[435] | 348 | def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
| 349 | def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
| 350 | render(view:'edit', model:[inventoryItemInstance: result.inventoryItemInstance.attach(), |
---|
| 351 | possibleAlternateItems: possibleAlternateItems, |
---|
| 352 | suppliers: suppliers, |
---|
| 353 | manufacturers: manufacturers]) |
---|
[116] | 354 | } |
---|
| 355 | |
---|
| 356 | def create = { |
---|
[405] | 357 | def result = inventoryItemService.create(params) |
---|
[435] | 358 | def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
| 359 | def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
[405] | 360 | |
---|
| 361 | if(!result.error) |
---|
[435] | 362 | return [inventoryItemInstance: result.inventoryItemInstance, |
---|
| 363 | suppliers: suppliers, |
---|
| 364 | manufacturers: manufacturers] |
---|
[405] | 365 | |
---|
| 366 | //flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 367 | redirect(action: search) |
---|
[116] | 368 | } |
---|
| 369 | |
---|
| 370 | def save = { |
---|
[405] | 371 | def result = inventoryItemService.save(params) |
---|
| 372 | |
---|
| 373 | if(!result.error) { |
---|
| 374 | flash.message = g.message(code: "default.create.success", args: ["InventoryItem", result.inventoryItemInstance.id]) |
---|
| 375 | redirect(action:show, id: result.inventoryItemInstance.id) |
---|
| 376 | return |
---|
[116] | 377 | } |
---|
[405] | 378 | |
---|
[435] | 379 | def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
| 380 | def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } |
---|
| 381 | |
---|
[405] | 382 | //flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
[435] | 383 | render(view:'create', model:[inventoryItemInstance: result.inventoryItemInstance, |
---|
| 384 | suppliers: suppliers, |
---|
| 385 | manufacturers: manufacturers]) |
---|
[116] | 386 | } |
---|
[225] | 387 | |
---|
| 388 | /** |
---|
| 389 | * Handles the use inventory item form submit in the show view. |
---|
| 390 | */ |
---|
[298] | 391 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
[225] | 392 | def useInventoryItem = { |
---|
| 393 | |
---|
[226] | 394 | params.inventoryMovementType = InventoryMovementType.get(1) // Set type to "Used". |
---|
[225] | 395 | def result = inventoryMovementService.move(params) |
---|
| 396 | |
---|
| 397 | if(!result.error) { |
---|
| 398 | flash.message = "Inventory Movement for ${result.inventoryMovementInstance.inventoryItem.name.encodeAsHTML()} created." |
---|
[453] | 399 | session.inventoryMovementTaskId = null |
---|
| 400 | redirect(controller: "taskDetailed", |
---|
| 401 | action: "show", |
---|
| 402 | id: result.taskId, |
---|
| 403 | params: [showTab: "showInventoryTab"]) |
---|
| 404 | // Success. |
---|
| 405 | return |
---|
[225] | 406 | } |
---|
| 407 | |
---|
[453] | 408 | // Prepare data for the show view. |
---|
| 409 | def p = [:] |
---|
| 410 | p.id = result.inventoryMovementInstance.inventoryItem?.id |
---|
| 411 | def r = inventoryItemService.show(p) |
---|
[225] | 412 | |
---|
[453] | 413 | // Render show view if data was successfully prepared. |
---|
| 414 | if(!r.error) { |
---|
| 415 | def model = [ inventoryItemInstance: r.inventoryItemInstance, |
---|
| 416 | inventoryMovementList: r.inventoryMovementList, |
---|
| 417 | inventoryMovementListTotal: r.inventoryMovementListTotal, |
---|
| 418 | inventoryMovementListMax: r.inventoryMovementListMax, |
---|
| 419 | inventoryItemPurchases: r.inventoryItemPurchases, |
---|
| 420 | inventoryItemPurchasesTotal: r.inventoryItemPurchasesTotal, |
---|
| 421 | showTab: r.showTab] |
---|
[225] | 422 | |
---|
[453] | 423 | model.inventoryMovementInstance = result.inventoryMovementInstance // This will pass in the errors. |
---|
[225] | 424 | |
---|
[453] | 425 | render(view: 'show', model: model) |
---|
| 426 | return |
---|
[225] | 427 | } |
---|
[453] | 428 | |
---|
| 429 | // Could not prepare data for show view so doing the next best thing. |
---|
| 430 | flash.errorMessage = g.message(code: r.error.code, args: r.error.args) |
---|
| 431 | redirect(action:search) |
---|
| 432 | |
---|
| 433 | } // useInventoryItem |
---|
| 434 | |
---|
| 435 | /** |
---|
| 436 | * Clear the use inventory item form in the show view. |
---|
| 437 | * Accomplished by clearing the session variable and ajax. |
---|
| 438 | */ |
---|
| 439 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser']) |
---|
| 440 | def clearUseInventoryItem = { |
---|
| 441 | session.inventoryMovementTaskId = null |
---|
| 442 | render '' |
---|
[225] | 443 | } |
---|
| 444 | |
---|
[453] | 445 | } // end of class |
---|