OSDN Git Service

- Add 'overtime' attribute for bookings to book off-hour time slots as
authorcs <cs@e1914e07-63f8-0310-9059-d6d858d7cdca>
Sat, 18 Feb 2006 10:54:52 +0000 (10:54 +0000)
committercs <cs@e1914e07-63f8-0310-9059-d6d858d7cdca>
Sat, 18 Feb 2006 10:54:52 +0000 (10:54 +0000)
  well.

git-svn-id: https://www.taskjuggler.org/svn/taskjuggler/trunk@1266 e1914e07-63f8-0310-9059-d6d858d7cdca

TODO
TestSuite/Scheduler/Correct/Booking1.tjp [new file with mode: 0644]
TestSuite/Syntax/Correct/Booking.tjp
docs/en/ChangeLog.xml
docs/en/PropertyReference.xml
docs/en/SyntaxReference.xml
docs/en/taskjuggler.xml.in
taskjuggler/ProjectFile.cpp
taskjuggler/Resource.cpp
taskjuggler/Resource.h

diff --git a/TODO b/TODO
index 1e487fa..fe22d08 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
 Work in progress:
-- 'allowoffhours' attribute for bookings
 - less verbose booking syntax
 - Split toolbar with zoom and scheduling icons.
 
diff --git a/TestSuite/Scheduler/Correct/Booking1.tjp b/TestSuite/Scheduler/Correct/Booking1.tjp
new file mode 100644 (file)
index 0000000..5a80fdc
--- /dev/null
@@ -0,0 +1,23 @@
+project prj "Project" "1.0" 2006-02-18-0:00-GMT +2m {
+  timezone "GMT"
+  scenario plan "Plan" { projection }
+}
+
+resource r1 "Resource 1" {
+  vacation 2006-02-19
+}
+
+task t1 "Task 1" {
+  start 2006-02-18
+  effort 2d
+  allocate r1
+}
+
+supplement resource r1 {
+  booking t1 2006-02-18-8:00 +8h { overtime 1 }
+  booking t1 2006-02-19-8:00 +8h { overtime 2 }
+}
+
+taskreport "Tasks" {
+  columns no, name, start, end, chart
+}
index 294cb06..d0a69ea 100644 (file)
@@ -1,4 +1,4 @@
-project prj "Project" "1.0" 2003-06-05 2003-07-05 {
+project prj "Project" "1.0" 2003-06-05 +1m {
   # The baseline date for the projection.
   now 2003-06-15
   scenario plan "Plan" {
@@ -18,7 +18,8 @@ task t1 "Task 1" {
 
 supplement resource r1 {
   # This is the work that has been done up until now by r1.
-  booking 2003-06-06 2003-06-07 t1 { sloppy 2 }
-  booking 2003-06-08 2003-06-09 t1 { sloppy 2 }
-  booking 2003-06-11 2003-06-12 t1 { sloppy 2 }
+  booking t1 2003-06-06 +8h { sloppy 2 }
+  booking t1 2003-06-08 +8h { sloppy 2 }
+  # Book interval that extends into off-hours.
+  booking t1 2003-06-11-8:00 +10h { overtime 1 }
 }
index 4992276..ff080ce 100644 (file)
@@ -922,6 +922,11 @@ inherited dependencies.</para></listitem>
 <listitem><para>Generate propper warning when bookings are assigned to
 container tasks or milestones.</para></listitem>
 
+<listitem><para>It is now possible to book off-hour and vacation time
+slots with 'booking' when the <link
+linkend="PROPERTY_overtime">overtime</link> attribute is
+used.</para></listitem>
+
 </itemizedlist></para>
 
 </sect2>
index 6a3ac2f..b30ec69 100644 (file)
@@ -301,11 +301,11 @@ HTML calendar columns. The default is to show load values.</para></descr>
   given, all bookings must only cover working time for the
   resource.</para></descr>
   <attributes>
-   <attr name="start" type="DATE"/>
-   <attr name="end" type="DATE"/>
    <attr name="task" type="ID"/>
+   <attr name="period" type="DATEINTERVAL"/>
   </attributes>
   <optattributes>
+   <optattr>overtime</optattr>
    <optattr>sloppy</optattr>
   </optattributes>
   <seealso>
@@ -1658,6 +1658,30 @@ should be shown at a maximum.</para></descr>
   </attributes>
   <example>&example_numberformat;</example>
  </property>
+ <property name="overtime" id="overtime" inheritable="No">
+  <descr><para>This attribute enables bookings to override working
+  hours and vacations.</para></descr>
+  <attributes>
+   <attr name="value" type="INTEGER">
+    <para>Number between 0 and 2. See table below.</para>
+   </attr>
+  </attributes>
+  <freestyle>
+   <para><simplelist type="horiz" columns="2">
+   
+   <member><varname>overtime 0:</varname></member>
+   <member>You can only book available working hours. (Default)</member>
+
+   <member><varname>overtime 1:</varname></member>
+   <member>You can book off-hours as well.</member>
+   
+   <member><varname>overtime 2:</varname></member>
+   <member>You can book normal working hours, off-hours and vacations.</member>
+
+   </simplelist></para>
+  </freestyle>
+  <example>&example_booking;</example>
+ </property>
  <property name="persistent" id="persistent" inheritable="No">
   <descr><para>Specifies that once a resource is picked from the list
   of alternatives this resource is used for the whole task.
@@ -1731,11 +1755,9 @@ specified to terminate the scheduling process.</para></descr>
     <para>The version of the project file. This could be a revision
 number from a revision control system.</para>
    </attr>
-   <attr name="start" type="DATE">
-    <para>All task must start after this date.</para>
-   </attr>
-   <attr name="end" type="DATE">
-    <para>All task must end before this date.</para>
+   <attr name="period" type="DATEINTERVAL">
+    <para>The expected interval of the project. It may be larger than
+    necessary, but it needs to be large enough to fit all tasks.</para>
    </attr>
   </attributes>
   <optattributes>
@@ -2211,7 +2233,7 @@ contain the project ID after the load value.</para></descr>
    
    <member><varname>sloppy 0:</varname></member>
    <member>Period may not contain any off-duty hours, vacation or
-   other task assignments.</member>
+   other task assignments. (Default)</member>
 
    <member><varname>sloppy 1:</varname></member>
    <member>Period may contain off-duty hours, but not vacation or
index 9f65f96..28fabcd 100644 (file)
@@ -34,6 +34,12 @@ specifies the interval duration. In this form the start date
 is followed by a plus character. The plus character must be separated
 from the start date by a space or newline character. The plus must be
 followed by a number and a <link linkend="TYPE_UNIT">UNIT</link>.</para>
+
+<para><screen>2006-02-18 - 2006-02-19
+2006-02-18
+2006-02-18 +1d
+</screen></para>
+
 </sect2>
 <sect2 id="TYPE_GLOBAL_ID"><title>GLOBAL_ID</title>
 
@@ -66,8 +72,7 @@ A-Z, a-z, 0-9, and _.  It may not start with a number.</para>
        flagBar are declared flags, the following example is a correct
        expression:</para>
 
-<para><screen>
-(flagFoo | flagFooBar) &amp; &tilde;flagBar
+<para><screen>(flagFoo | flagFooBar) &amp; &tilde;flagBar
 </screen></para>
 
 <para>The following functions can be used in logical expressions:
index 65520d9..7e2417c 100644 (file)
@@ -18,7 +18,7 @@
 </author>
 </authorgroup>
 <copyright>
-       <year>2001, 2002, 2003, 2004, 2005</year>
+       <year>2001, 2002, 2003, 2004, 2005, 2006</year>
        <holder>Chris Schl&auml;ger</holder>
 </copyright>
 <date>Version @VERSION@</date>
index 4b56c42..24f9d1f 100644 (file)
@@ -2394,11 +2394,12 @@ ProjectFile::readBooking(int sc, Resource* resource)
 
 
     int sloppy = 0;
+    int overtime = 0;
     if ((tt = nextToken(token)) == LBRACE)
     {
         while ((tt = nextToken(token)) != RBRACE)
         {
-            if (token == "sloppy")
+            if (token == KW("sloppy"))
             {
                 if (nextToken(token) != INTEGER ||
                     token.toInt() < 0 || token.toInt() > 3)
@@ -2408,6 +2409,16 @@ ProjectFile::readBooking(int sc, Resource* resource)
                 }
                 sloppy = token.toInt();
             }
+            else if (token == KW("overtime"))
+            {
+                if (nextToken(token) != INTEGER ||
+                    token.toInt() < 0 || token.toInt() > 2)
+                {
+                    errorMessage(i18n("Number between 0 and 2 expected"));
+                    return 0;
+                }
+                overtime = token.toInt();
+            }
             else
             {
                 errorMessage(i18n("Attribute ID expected"));
@@ -2419,7 +2430,7 @@ ProjectFile::readBooking(int sc, Resource* resource)
         returnToken(tt, token);
 
     Booking* b = new Booking(iv, task);
-    if (!resource->addBooking(sc, b, sloppy))
+    if (!resource->addBooking(sc, b, sloppy, overtime))
         return false;
 
     return true;
index 626d624..04d74a9 100644 (file)
@@ -518,14 +518,14 @@ Resource::book(Booking* nb)
 {
     uint idx = sbIndex(nb->getStart());
 
-    return bookSlot(idx, nb);
+    return bookSlot(idx, nb, 0);
 }
 
 bool
-Resource::bookSlot(uint idx, SbBooking* nb)
+Resource::bookSlot(uint idx, SbBooking* nb, int overtime)
 {
     // Make sure that the time slot is still available.
-    if (scoreboard[idx] != 0)
+    if (scoreboard[idx] > (SbBooking*) overtime)
     {
         delete nb;
         return FALSE;
@@ -553,7 +553,7 @@ Resource::bookSlot(uint idx, SbBooking* nb)
 }
 
 bool
-Resource::bookInterval(Booking* nb, int sc, int sloppy)
+Resource::bookInterval(Booking* nb, int sc, int sloppy, int overtime)
 {
     uint sIdx = sbIndex(nb->getStart());
     uint eIdx = sbIndex(nb->getEnd());
@@ -561,7 +561,7 @@ Resource::bookInterval(Booking* nb, int sc, int sloppy)
     bool conflict = FALSE;
 
     for (uint i = sIdx; i <= eIdx; i++)
-        if (scoreboard[i])
+        if (scoreboard[i] > (SbBooking*) overtime)
         {
             uint j;
             for (j = i + 1 ; j <= eIdx &&
@@ -625,13 +625,14 @@ Resource::bookInterval(Booking* nb, int sc, int sloppy)
         return FALSE;
 
     for (uint i = sIdx; i <= eIdx; i++)
-        bookSlot(i, new SbBooking(*nb));
+        if (scoreboard[i] <= (SbBooking*) overtime)
+            bookSlot(i, new SbBooking(*nb), overtime);
 
     return TRUE;
 }
 
 bool
-Resource::addBooking(int sc, Booking* nb, int sloppy)
+Resource::addBooking(int sc, Booking* nb, int sloppy, int overtime)
 {
     SbBooking** tmp = scoreboard;
 
@@ -639,7 +640,7 @@ Resource::addBooking(int sc, Booking* nb, int sloppy)
         scoreboard = scoreboards[sc];
     else
         initScoreboard();
-    bool retVal = bookInterval(nb, sc, sloppy);
+    bool retVal = bookInterval(nb, sc, sloppy, overtime);
     // Cross register booking with task.
     if (retVal && nb->getTask())
         nb->getTask()->addBookedResource(sc, this);
index 3ae439d..1e0b1bf 100644 (file)
@@ -112,9 +112,9 @@ public:
 
     bool book(Booking* b);
 
-    bool bookSlot(uint idx, SbBooking* nb);
-    bool bookInterval(Booking* b, int sc, int sloppy = 0);
-    bool addBooking(int sc, Booking* b, int sloppy = 0);
+    bool bookSlot(uint idx, SbBooking* nb, int overtime = 0);
+    bool bookInterval(Booking* b, int sc, int sloppy = 0, int overtime = 0);
+    bool addBooking(int sc, Booking* b, int sloppy = 0, int overtime = 0);
 
     double getCurrentLoad(const Interval& i, const Task* task = 0) const;