Changeset 468 for trunk/grails-app/controllers
- Timestamp:
- Mar 30, 2010, 10:01:10 PM (15 years ago)
- Location:
- trunk/grails-app/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy
r441 r468 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 import org.codehaus.groovy.grails.commons.ConfigurationHolder 3 import com.zeddware.grails.plugins.filterpane.FilterUtils 2 4 3 5 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager']) … … 5 7 6 8 def authService 9 def filterService 10 def exportService 11 def dateUtilService 7 12 def inventoryPurchaseService 8 13 9 14 def index = { 10 redirect( controller: 'inventoryItemDetailed',action:'search', params:params)15 redirect(action:'search', params:params) 11 16 } 12 17 13 18 // the delete, save and update actions only accept POST requests 14 19 static allowedMethods = [delete:'POST', save:'POST', update:'POST'] 20 21 def setSearchParamsMax = { 22 def max = 1000 23 if(params.newMax.isInteger()) { 24 def i = params.newMax.toInteger() 25 if(i > 0 && i <= max) 26 session.inventoryItemPurchaseSearchParamsMax = params.newMax 27 if(i > max) 28 session.inventoryItemPurchaseSearchParamsMax = max 29 } 30 forward(action: 'search', params: params) 31 } 32 33 def search = { 34 35 if(session.inventoryItemPurchaseSearchParamsMax) 36 params.max = session.inventoryItemPurchaseSearchParamsMax 37 38 // Protect filterPane. 39 params.max = Math.min( params.max ? params.max.toInteger() : 10, 1000 ) 40 params.offset = params.offset?.toInteger() ?: 0 41 params.sort = params.sort ?: "purchaseOrderNumber" 42 params.order = params.order ?: "desc" 43 44 def inventoryItemPurchaseList = [] 45 def inventoryItemPurchaseTotal 46 def filterParams = [:] 47 48 // Quick Search: 49 if(!FilterUtils.isFilterApplied(params)) { 50 51 if(params.quickSearch == "searchAllOrders") { 52 inventoryItemPurchaseList = InventoryItemPurchase.findAllByInventoryItemPurchaseType(InventoryItemPurchaseType.read(1), 53 [max:params.max, 54 offset:params.offset, 55 sort:params.sort, 56 order:params.order]) 57 if(inventoryItemPurchaseList.size() > 0) { params.message = "All Orders." } 58 else { params.message = "No orders found." } 59 } 60 else if(params.quickSearch == "searchAllReceived") { 61 inventoryItemPurchaseList = InventoryItemPurchase.findAllByInventoryItemPurchaseTypeOrInventoryItemPurchaseType(InventoryItemPurchaseType.read(2), 62 InventoryItemPurchaseType.read(3), 63 [max:params.max, 64 offset:params.offset, 65 sort:params.sort, 66 order:params.order]) 67 if(inventoryItemPurchaseList.size() > 0) { params.message = "All Received Complete." } 68 else { params.message = "No orders found." } 69 } 70 else { 71 //Default: 72 inventoryItemPurchaseList = InventoryItemPurchase.list(max:params.max, 73 offset:params.offset, 74 sort:params.sort, 75 order:params.order) 76 if(inventoryItemPurchaseList.size() > 0) { params.message = "All Purchases." } 77 else { params.message = "No orders found." } 78 } 79 80 inventoryItemPurchaseTotal = inventoryItemPurchaseList.size() 81 filterParams.quickSearch = params.quickSearch 82 } 83 else { 84 // filterPane: 85 inventoryItemPurchaseList = filterService.filter( params, InventoryItemPurchase ) 86 inventoryItemPurchaseTotal = filterService.count( params, InventoryItemPurchase ) 87 filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) 88 } 89 90 // export plugin: 91 if(params?.format && params.format != "html") { 92 93 def dateFmt = { date -> 94 formatDate(format: "EEE, dd-MMM-yyyy", date: date) 95 } 96 97 String title 98 if(params.quickSearch) 99 title = "${params.quickSearch} inventory purchases." 100 else 101 title = "Filtered inventory purchases." 102 103 response.contentType = ConfigurationHolder.config.grails.mime.types[params.format] 104 response.setHeader("Content-disposition", "attachment; filename=Purchases.${params.extension}") 105 List fields = ["purchaseOrderNumber", "dateEntered", "costCode", "quantity", "orderValueAmount", "invoiceNumber", 106 "inventoryItemPurchaseType"] 107 Map labels = ["purchaseOrderNumber": "Order Number", "dateEntered": "Date", "costCode": "Cost Code", 108 "quantity": "Quantity", "orderValueAmount": "Order \$", "invoiceNumber": "Invoice Number", 109 "inventoryItemPurchaseType": "Type"] 110 Map formatters = [ dateEntered: dateFmt] 111 Map parameters = [title: title, separator: ","] 112 113 exportService.export(params.format, response.outputStream, inventoryItemPurchaseList, fields, labels, formatters, parameters) 114 } 115 116 // Add some basic params to filterParams. 117 filterParams.max = params.max 118 filterParams.offset = params.offset?.toInteger() ?: 0 119 filterParams.sort = params.sort ?: "purchaseOrderNumber" 120 filterParams.order = params.order ?: "desc" 121 122 return[ inventoryItemPurchaseList: inventoryItemPurchaseList, 123 inventoryItemPurchaseTotal: inventoryItemPurchaseTotal, 124 filterParams: filterParams ] 125 126 } // end search() 15 127 16 128 def show = { -
trunk/grails-app/controllers/TaskDetailedController.groovy
r465 r468 40 40 params.max = session.taskSearchParamsMax 41 41 42 // TaskSearchService protects itself but filterPane does not.42 // Protect filterPane. 43 43 params.max = Math.min( params.max ? params.max.toInteger() : 10, 1000 ) 44 44
Note: See TracChangeset
for help on using the changeset viewer.