Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implemented the date range for adding scheduling items using joda tim…

…e and week numbers
  • Loading branch information...
commit 580da9dd2892526a6991c1edd52e8e562bfb8b22 1 parent cdbbf04
@jettro authored
View
2  grails-app/conf/UrlMappings.groovy
@@ -5,7 +5,7 @@ class UrlMappings {
// apply constraints here
}
}
- "/"(view:"/index")
+ "/"(controller:"home", action:"index")
"500"(view:'/error')
}
}
View
13 grails-app/controllers/nl/gridshore/scheduling/SchedulingController.groovy
@@ -1,6 +1,7 @@
package nl.gridshore.scheduling
import grails.converters.JSON
+import org.joda.time.LocalDate
class SchedulingController {
def scheduleItemService;
@@ -20,10 +21,18 @@ class SchedulingController {
def personName = params.person
def projectName = params.project
def nrHours = params.nrhours.toInteger()
- def weekNr = params.weeknr.toInteger()
+ def startDateStr = params.startDate
+ def endDateStr = params.endDate
+ if (startDateStr && endDateStr) {
+ LocalDate startDate = new LocalDate(startDateStr)
+ LocalDate endDate = new LocalDate(endDateStr)
+ scheduleItemService.createScheduleItems(personName, projectName, nrHours,startDate,endDate)
+ } else {
+ def weekNr = params.weeknr.toInteger()
+ scheduleItemService.createScheduleItem(personName, projectName, weekNr, nrHours)
+ }
flash.message = "New item is created for person ${personName} and project ${projectName}"
- scheduleItemService.createScheduleItem(personName, projectName, weekNr, nrHours)
redirect(action: "create")
}
View
17 grails-app/services/nl/gridshore/scheduling/ScheduleItemService.groovy
@@ -1,14 +1,23 @@
package nl.gridshore.scheduling
+import org.joda.time.LocalDate
+import org.joda.time.Period
+
class ScheduleItemService {
boolean transactional = true
- def createScheduleItems(long personId, long projectId,int numberHours,int weekNr,
- Date startDate, Date endDate) {
+ def createScheduleItems(String personName, String projectName,int numberHours,LocalDate startDate, LocalDate endDate) {
// determine the start and end date
-
- doCreateScheduleItem(person, project, weekNr, numberHours)
+ def project = Project.findByName(projectName)
+ def person = Person.findByName(personName)
+ // TODO jettro : denk aan probleem met weken over de jaargrens heen
+ // TODO jettro : wellicht een warning als het te lang is??
+ def currentDate = startDate
+ for (int i=startDate.weekOfWeekyear;i<endDate.weekOfWeekyear;i++) {
+ currentDate = currentDate + Period.weeks(1)
+ doCreateScheduleItem(person, project, i, numberHours)
+ }
}
def createScheduleItem(String personName, String projectName, int weekNr, int numberHours) {
View
5 grails-app/views/scheduling/create.gsp
@@ -18,9 +18,10 @@
</div>
<div class="yui-skin-sam">
- <gui:datePicker id="startDate"/>
- <gui:datePicker id="endDate"/>
+ <gui:datePicker id="startDate" formatString="yyyy-MM-dd"/>
+ <gui:datePicker id="endDate" formatString="yyyy-MM-dd"/>
</div>
+ <g:submitButton name="Create"/>
</g:form>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.