Ignore:
Timestamp:
Oct 23, 2009, 1:00:23 PM (15 years ago)
Author:
gav
Message:

Install export plugin.
Add budget 'planned' and 'unplanned' search view.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r155 r165  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2import org.codehaus.groovy.grails.commons.ConfigurationHolder
    23
    34class TaskDetailedController extends BaseController {
     
    78    def taskSearchService
    89    def filterService
     10    def exportService
    911
    1012    // the delete, save and update actions only accept POST requests
     
    102104        return[ taskInstanceList: filterService.filter( params, Task ),
    103105            taskInstanceTotal: taskInstanceTotal,
     106            filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),
     107            params:params ]
     108    }
     109
     110    def budget = {
     111//         println params
     112        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100 )
     113
     114        // Quick Search:
     115        if(!params.filter)
     116        {
     117            def taskInstanceList = []
     118            def personInstance = Person.get(authenticateService.userDomain().id)
     119
     120            if(params.quickSearch == "budgetUnplanned") {
     121                taskInstanceList = taskSearchService.getBudgetUnplanned(params)
     122                if(taskInstanceList.totalCount > 0) { params.message = "Budget unplanned tasks in the last week." }
     123                else { params.message = "No tasks found." }
     124            }
     125            //else if(params.quickSearch == "budgetPlanned") {
     126            else {
     127                //Default:
     128                taskInstanceList = taskSearchService.getBudgetPlanned(params)
     129                if(taskInstanceList.totalCount > 0) { params.message = "Budget planned Tasks in the last week." }
     130                else { params.message = "No tasks found.." }
     131            }
     132            // export plugin:
     133            if(params?.format && params.format != "html") {
     134                response.contentType = ConfigurationHolder.config.grails.mime.types[params.format]
     135                response.setHeader("Content-disposition", "attachment; filename=tasks.${params.extension}")
     136                List fields = ["id", "targetStartDate", "description", "leadPerson", "taskStatus", "taskType"]
     137                Map labels = ["id": "ID", "targetStartDate": "Target Start Date", "description": "Description",
     138                                        "leadPerson": "Lead Person", "taskStatus": "Task Status", "taskType": "Task Type"]
     139                Map formatters = [:]
     140                String title = "${params.quickSearch} tasks in the last week."
     141                Map parameters = [title: title]
     142
     143                exportService.export(params.format, response.outputStream, taskInstanceList, fields, labels, formatters, parameters)
     144            }
     145            return[taskInstanceList: taskInstanceList, taskInstanceTotal: taskInstanceList.totalCount, filterParams: params]
     146        }
     147        // filterPane:
     148        return[ taskInstanceList: filterService.filter( params, Task ),
     149            taskInstanceTotal: filterService.count( params, Task ),
    104150            filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),
    105151            params:params ]
Note: See TracChangeset for help on using the changeset viewer.