]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Patch for bug 103636: Support specifying a date on which a bug is expected to be...
authorjocuri%softhome.net <>
Sun, 16 Jan 2005 21:36:02 +0000 (21:36 +0000)
committerjocuri%softhome.net <>
Sun, 16 Jan 2005 21:36:02 +0000 (21:36 +0000)
19 files changed:
Bugzilla/Bug.pm
Bugzilla/BugMail.pm
Bugzilla/Search.pm
Bugzilla/Util.pm
CGI.pl
buglist.cgi
checksetup.pl
colchange.cgi
globals.pl
long_list.cgi
post_bug.cgi
process_bug.cgi
template/en/default/bug/create/create.html.tmpl
template/en/default/bug/edit.html.tmpl
template/en/default/bug/show-multiple.html.tmpl
template/en/default/filterexceptions.pl
template/en/default/global/field-descs.none.tmpl
template/en/default/global/user-error.html.tmpl
template/en/default/search/form.html.tmpl

index d5aa5fd171fe3ee32472226fe82a2e4835e3e28b..bad24b589e35d60a32c7b441c39111ff615fd6a7 100755 (executable)
@@ -62,7 +62,7 @@ sub fields {
     }
 
     if (Param('timetrackinggroup')) {
-        push @fields, qw(estimated_time remaining_time actual_time);
+        push @fields, qw(estimated_time remaining_time actual_time deadline);
     }
 
     return @fields;
@@ -147,7 +147,7 @@ sub initBug  {
       DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'),
       delta_ts, COALESCE(SUM(votes.vote_count), 0),
       reporter_accessible, cclist_accessible,
-      estimated_time, remaining_time
+      estimated_time, remaining_time, DATE_FORMAT(deadline,'%Y-%m-%d')
     from bugs left join votes using(bug_id),
       classifications, products, components
     where bugs.bug_id = $bug_id
@@ -170,7 +170,7 @@ sub initBug  {
                        "target_milestone", "qa_contact", "status_whiteboard", 
                        "creation_ts", "delta_ts", "votes",
                        "reporter_accessible", "cclist_accessible",
-                       "estimated_time", "remaining_time")
+                       "estimated_time", "remaining_time", "deadline")
       {
         $fields{$field} = shift @row;
         if (defined $fields{$field}) {
index 41a8c23294e22e05e4c083915718c11250d7a8a5..d9dbb770bcf0d27873dfbc3425e389888896c4a9 100644 (file)
@@ -184,6 +184,8 @@ sub ProcessOneBug($) {
     }
     $values{'estimated_time'} = format_time_decimal($values{'estimated_time'});
 
+    $values{'deadline'} = time2str("%Y-%m-%d", str2time($values{'deadline'}));
+
     my @dependslist;
     SendSQL("SELECT dependson FROM dependencies WHERE 
              blocked = $id ORDER BY dependson");
@@ -243,6 +245,10 @@ sub ProcessOneBug($) {
                      WHERE attach_id = $attachid");
             $diffpart->{'isprivate'} = FetchOneColumn();
         }
+        if( $fieldname eq 'deadline' ) {
+            $old = time2str("%Y-%m-%d", str2time($old));
+            $new = time2str("%Y-%m-%d", str2time($new));
+        }  
         $difftext = FormatTriple($what, $old, $new);
         $diffpart->{'header'} = $diffheader;
         $diffpart->{'fieldname'} = $fieldname;
@@ -741,8 +747,8 @@ sub NewProcessOnePerson ($$$$$$$$$$$$$) {
           next;
         }
         # Only send estimated_time if it is enabled and the user is in the group
-        if ($f ne 'estimated_time' ||
-            $user->groups->{Param('timetrackinggroup')}) {
+        if (($f ne 'estimated_time' && $f ne 'deadline') ||
+             $user->groups->{Param('timetrackinggroup')}) {
 
             my $desc = $fielddescription{$f};
             $head .= FormatDouble($desc, $value);
@@ -761,7 +767,8 @@ sub NewProcessOnePerson ($$$$$$$$$$$$$) {
         if (exists($diff->{'fieldname'}) && 
             ($diff->{'fieldname'} eq 'estimated_time' ||
              $diff->{'fieldname'} eq 'remaining_time' ||
-             $diff->{'fieldname'} eq 'work_time')) {
+             $diff->{'fieldname'} eq 'work_time' ||
+             $diff->{'fieldname'} eq 'deadline')){
             if ($user->groups->{Param("timetrackinggroup")}) {
                 $add_diff = 1;
             }
index 85f661e308963232b683cd88891a51163630a301..9756a428d245bbb2743320a827fdae919f95ae1b 100644 (file)
@@ -301,6 +301,27 @@ sub init {
         }
     }
 
+    my $sql_deadlinefrom;
+    my $sql_deadlineto;
+    if (Bugzilla->user->in_group(Param('timetrackinggroup'))){
+      my $deadlinefrom;
+      my $deadlineto;
+            
+      if ($params->param('deadlinefrom')){
+        $deadlinefrom = $params->param('deadlinefrom');
+        Bugzilla::Util::ValidateDate($deadlinefrom, 'deadlinefrom');
+        $sql_deadlinefrom = &::SqlQuote($deadlinefrom);
+        push(@wherepart, "bugs.deadline >= $sql_deadlinefrom");
+      }
+      
+      if ($params->param('deadlineto')){
+        $deadlineto = $params->param('deadlineto');
+        Bugzilla::Util::ValidateDate($deadlineto, 'deadlineto');
+        $sql_deadlineto = &::SqlQuote($deadlineto);
+        push(@wherepart, "bugs.deadline <= $sql_deadlineto");
+      }
+    }  
+
     foreach my $f ("short_desc", "long_desc", "bug_file_loc",
                    "status_whiteboard") {
         if (defined $params->param($f)) {
@@ -545,6 +566,10 @@ sub init {
          "^content," => sub {
              ThrowUserError("search_content_without_matches");
          },
+         "^deadline,(?:lessthan|greaterthan|equals|notequals),(-|\\+)?(\\d+)([dDwWmMyY])\$" => sub {
+             $v = SqlifyDate($v);
+             $q = &::SqlQuote($v);
+        },
          "^commenter,(?:equals|anyexact),(%\\w+%)" => sub {
              my $match = pronoun($1, $user);
              my $chartseq = $chartid;
@@ -1281,9 +1306,12 @@ sub SqlifyDate {
         my ($sec, $min, $hour, $mday, $month, $year, $wday) = localtime(time());
         return sprintf("%4d-%02d-%02d 00:00:00", $year+1900, $month+1, $mday);
     }
-    if ($str =~ /^-?(\d+)([dDwWmMyY])$/) {   # relative date
-        my ($amount, $unit, $date) = ($1, lc $2, time);
+
+
+    if ($str =~ /^(-|\+)?(\d+)([dDwWmMyY])$/) {   # relative date
+        my ($sign, $amount, $unit, $date) = ($1, $2, lc $3, time);
         my ($sec, $min, $hour, $mday, $month, $year, $wday)  = localtime($date);
+        if ($sign eq '+') { $amount = -$amount; }
         if ($unit eq 'w') {                  # convert weeks to days
             $amount = 7*$amount + $wday;
             $unit = 'd';
index 142866912e43609a2015456d280e95a1fbbc3afa..b832d16987e16f24d2da67c3cdf47a7bc1a2fa71 100644 (file)
@@ -36,6 +36,9 @@ use base qw(Exporter);
                              format_time format_time_decimal);
 
 use Bugzilla::Config;
+use Bugzilla::Error;
+use Date::Parse;
+use Date::Format;
 
 # This is from the perlsec page, slightly modifed to remove a warning
 # From that page:
@@ -220,6 +223,20 @@ sub format_time_decimal {
     return $newtime;
 }
 
+sub ValidateDate {
+    my ($date, $format) = @_;
+
+    my $ts  = str2time($date);
+    my $date2 = time2str("%Y-%m-%d", $ts);
+
+    $date =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/; 
+    $date2 =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/;
+
+    if ($date ne $date2) {
+        ThrowUserError('illegal_date', {date => $date, format => $format});
+    } 
+}
+
 1;
 
 __END__
diff --git a/CGI.pl b/CGI.pl
index 822002957d82c41d17f11dab9a4bd696f8b4f5dc..165e5216ca43a689ed033bde5ad03ed0461626f3 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -358,7 +358,8 @@ sub GetBugActivity {
         # check if the user should see this field's activity
         if ($fieldname eq 'remaining_time' ||
             $fieldname eq 'estimated_time' ||
-            $fieldname eq 'work_time') {
+            $fieldname eq 'work_time' ||
+            $fieldname eq 'deadline') {
 
             if (!UserInGroup(Param('timetrackinggroup'))) {
                 $activity_visible = 0;
@@ -391,6 +392,11 @@ sub GetBugActivity {
                 $operation = {};
                 $changes = [];
             }  
+            
+            if ($fieldname eq 'deadline') {
+                $removed = time2str("%Y-%m-%d", str2time($removed));
+                $added = time2str("%Y-%m-%d", str2time($added));
+            }
         
             $operation->{'who'} = $who;
             $operation->{'when'} = $when;            
index 569cfdc9fb97c9b33eba85de806b686d38ef619a..4286f81f40ea9dbf12909759f239670f0a1171aa 100755 (executable)
@@ -478,7 +478,7 @@ DefineColumn("remaining_time"    , "bugs.remaining_time"        , "Remaining Hou
 DefineColumn("actual_time"       , "(SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id)) AS actual_time", "Actual Hours");
 DefineColumn("percentage_complete","(100*((SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id))/((SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id))+bugs.remaining_time))) AS percentage_complete", "% Complete"); 
 DefineColumn("relevance"         , "relevance"                  , "Relevance"        );
-
+DefineColumn("deadline"          , "DATE_FORMAT(bugs.deadline, '%Y-%m-%d')", "Deadline");
 
 ################################################################################
 # Display Column Determination
@@ -544,6 +544,7 @@ if (!UserInGroup(Param("timetrackinggroup"))) {
    @displaycolumns = grep($_ ne 'remaining_time', @displaycolumns);
    @displaycolumns = grep($_ ne 'actual_time', @displaycolumns);
    @displaycolumns = grep($_ ne 'percentage_complete', @displaycolumns);
+   @displaycolumns = grep($_ ne 'deadline', @displaycolumns);
 }
 
 # Remove the relevance column if the user is not doing a fulltext search.
index bf193497a5869d1e5d3e28704568e10446f7ffb5..932870dd2008b26340546f3d56defdfa189fda9c 100755 (executable)
@@ -1774,6 +1774,7 @@ $table{bugs} =
     cclist_accessible tinyint not null default 1,
     estimated_time decimal(5,2) not null default 0,
     remaining_time decimal(5,2) not null default 0,
+    deadline datetime,
     alias varchar(20),
     
     index (assigned_to),
@@ -2287,6 +2288,7 @@ AddFDef("cclist_accessible", "CC Accessible", 0);
 AddFDef("bug_group", "Group", 0);
 AddFDef("estimated_time", "Estimated Hours", 1);
 AddFDef("remaining_time", "Remaining Hours", 0);
+AddFDef("deadline", "Deadline", 1);
 
 # Oops. Bug 163299
 $dbh->do("DELETE FROM fielddefs WHERE name='cc_accessible'");
@@ -3354,6 +3356,7 @@ if (GetFieldDef("bugs","qacontact_accessible")) {
 AddField("longdescs", "work_time", "decimal(5,2) not null default 0");
 AddField("bugs", "estimated_time", "decimal(5,2) not null default 0");
 AddField("bugs", "remaining_time", "decimal(5,2) not null default 0");
+AddField("bugs", "deadline", "datetime");
 
 # 2002-03-15 bbaetz@student.usyd.edu.au - bug 129466
 # 2002-05-13 preed@sigkill.com - bug 129446 patch backported to the 
index 1886b6b07d6c6a0a6285043e0b36d9939d44e763..8e2fc2d49ad4ff5bbfdbc1ec6d7ca8ac059b539b 100755 (executable)
@@ -77,7 +77,7 @@ if (@::legal_keywords) {
 
 if (UserInGroup(Param("timetrackinggroup"))) {
     push(@masterlist, ("estimated_time", "remaining_time", "actual_time",
-                       "percentage_complete")); 
+                       "percentage_complete", "deadline")); 
 }
 
 push(@masterlist, ("short_desc", "short_short_desc"));
index dc0a295706a28aeb3474d4a4ccf10e00eb1beec3..00a44af7af0376d55276a91c900060aa6c805586 100644 (file)
@@ -681,7 +681,7 @@ sub GetFieldDefs {
     my $extra = "";
     if (!UserInGroup(Param('timetrackinggroup'))) {
         $extra = "WHERE name NOT IN ('estimated time', 'remaining_time', " .
-                 "'work_time', 'percentage_complete')";
+                 "'work_time', 'percentage_complete', 'deadline')";
     }
 
     my @fields;
index 515f4c2260d9e2256ccb367da360a28339455268..c3abbafcfd5f540661d36516101856059f4922dd 100755 (executable)
@@ -63,7 +63,8 @@ my $generic_query = "
     bugs.keywords,
     bugs.estimated_time,
     bugs.remaining_time,
-    date_format(creation_ts,'%Y.%m.%d %H:%i')
+    date_format(creation_ts,'%Y.%m.%d %H:%i'),
+    date_format(bugs.deadline, '%Y-%m-%d')
   FROM bugs,profiles assign,profiles report, classifications, products, components
   WHERE assign.userid = bugs.assigned_to AND report.userid = bugs.reporter
     AND bugs.product_id=products.id AND bugs.component_id=components.id
@@ -89,7 +90,8 @@ foreach my $bug_id (split(/[:,]/, $buglist)) {
                        "bug_severity", "component", "assigned_to", "reporter",
                        "bug_file_loc", "short_desc", "target_milestone",
                        "qa_contact", "status_whiteboard", "keywords", 
-                       "estimated_time", "remaining_time", "creation_ts") 
+                       "estimated_time", "remaining_time", "creation_ts",
+                       "deadline")
     {
         $bug{$field} = shift @row;
     }
index 27f870e13303049a9a2183dfb70c185f74d0c0a1..b51e24db51d27010bdde85d956117e7e2c605546 100755 (executable)
@@ -325,7 +325,7 @@ if (UserInGroup("editbugs") && defined($::FORM{'dependson'})) {
 # Build up SQL string to add bug.
 my $sql = "INSERT INTO bugs " . 
   "(" . join(",", @used_fields) . ", reporter, creation_ts, " .
-  "estimated_time, remaining_time) " .
+  "estimated_time, remaining_time, deadline) " .
   "VALUES (";
 
 foreach my $field (@used_fields) {
@@ -346,10 +346,19 @@ if (UserInGroup(Param("timetrackinggroup")) &&
 
     my $est_time = $::FORM{'estimated_time'};
     Bugzilla::Bug::ValidateTime($est_time, 'estimated_time');
-    $sql .= SqlQuote($est_time) . "," . SqlQuote($est_time);
+    $sql .= SqlQuote($est_time) . "," . SqlQuote($est_time) . ",";
 } else {
-    $sql .= "0, 0";
+    $sql .= "0, 0";
 }
+
+if ((UserInGroup(Param("timetrackinggroup"))) && ($::FORM{'deadline'})) {
+    Bugzilla::Util::ValidateDate($::FORM{'deadline'}, 'YYYY-MM-DD');
+    my $str = $::FORM{'deadline'};
+    $sql .= SqlQuote($::FORM{'deadline'});  
+} else {
+    $sql .= "NULL";
+}
+
 $sql .= ")";
 
 # Groups
index d8ad4cafa26c1ad554caeb6c4dad2e29f6e77c55..724c709d89ebceb6b37432fefc05d34aa3e90617 100755 (executable)
@@ -784,6 +784,17 @@ if (UserInGroup(Param('timetrackinggroup'))) {
             }
         }
     }
+
+    if (defined $::FORM{'deadline'}) {
+        DoComma();
+        $::query .= "deadline = ";
+        if ($::FORM{'deadline'}) {
+            Bugzilla::Util::ValidateDate($::FORM{'deadline'}, 'YYYY-MM-DD');
+            $::query .= SqlQuote($::FORM{'deadline'});
+        } else {
+            $::query .= "NULL" ;
+        }
+    }
 }
 
 # If the user is submitting changes from show_bug.cgi for a single bug,
index 0bc5c516c1effb1139be0913d4dc485ddacb99cb..e3551627be6f768214dfa686ae858c450d3ab758 100644 (file)
@@ -218,6 +218,13 @@ function set_assign_to() {
       <input name="estimated_time" size="6" maxlength="6" value="0.0">
     </td>
   </tr>
+  <tr>
+    <td align="right"><strong>Deadline:</strong></td>
+    <td colspan="3">
+      <input name="deadline" size="10" maxlength="10">
+      <small>(YYYY-MM-DD)</small>
+    </td>
+  </tr>
 
   <tr>
     <td>&nbsp;</td>
index 3a9fed0c7bef9d35fd1bbe623d3c6f0d71fe3e8a..0ba3638d8543c686f48f11f62190bf36b6975033 100644 (file)
         <th align="center" bgcolor="#cccccc">
           Gain
         </th>
+        <th align="center" bgcolor="#cccccc">
+          Deadline
+        </th>
       </tr>
       <tr>
         <td align="center">
         <td align="center">
           [% PROCESS formattimeunit time_unit=bug.estimated_time - (bug.actual_time + bug.remaining_time) %]
         </td>
+         <td align="center">
+           <input name="deadline" value="[% bug.deadline %]"
+                  size="10" maxlength="10">
+        </td>        
       </tr>
     </table>
   [% END %]
index a6c5fccea9819d0d7f23b57cceed41c43e2c3a7f..a574450841fca0704ce51de88b7a2662ccc0a403 100644 (file)
           [% PROCESS formattimeunit
                      time_unit=bug.estimated_time - (bug.actual_time + bug.remaining_time) %]
           &nbsp;
+          <b>Deadline:</b>&nbsp;
+          [% bug.deadline %]
         </td>
       </tr>
     [% END %]
index b954c91761a5ee9f5cd52ef13d7e2073e1e7a7c6..3d5ba8fb1be45246b64b1659d8bbbd646f3219fc 100644 (file)
 ],
 
 'bug/edit.html.tmpl' => [
+  'bug.deadline',
   'bug.remaining_time', 
   'bug.delta_ts', 
   'bug.bug_id', 
 
 'bug/show-multiple.html.tmpl' => [
   'bug.bug_id', 
+  'bug.deadline',
 ],
 
 'bug/show.xml.tmpl' => [
index e49db6b5bf8b6ad02a8c67220efcbb1ea73ed6af..a1a22d7e8cf3f403ed17101218080d9a276d3cf1 100644 (file)
@@ -38,6 +38,7 @@
                    "component_id"         => "Component ID",
                    "component"            => "Component",
                    "creation_ts"          => "$terms.Bug Creation time",
+                   "deadline"             => "Deadline",
                    "delta_ts"             => "Last Changed time",
                    "dependson"            => "Depends on",
                    "dup_id"               => "Duplicate",
index 6b922d0c29ebb315c284269e26a52c732cd292ef..7c6b40201734f4f62d14c817ae3900ce24415226 100644 (file)
   [% ELSIF error == "illegal_date" %]
     [% title = "Illegal Date" %]
     '<tt>[% date FILTER html %]</tt>' is not a legal date.
+    [% IF format %]
+      Please use the format '<tt>[% format FILTER html %]</tt>'.
+    [% END %]
     
   [% ELSIF error == "illegal_email_address" %]
     [% title = "Invalid Email Address" %]
index a3e0d68f512a2856dd3efcec55f376c197a50442..35a85710d799887c8fcb06423a9998dede0dc2df 100644 (file)
@@ -304,6 +304,25 @@ function doOnSelectProduct(selectmode) {
       </td>
     </tr>
   [% END %]
+
+  [%# Deadline %]
+  [% IF UserInGroup(Param("timetrackinggroup")) %]
+    <tr>
+      <th align="right">
+        Dead<u>l</u>ine:
+      </th>
+      <td>
+        from&nbsp;
+        <input name="deadlinefrom" size="10" maxlength="10" accesskey="l">&nbsp;
+        to&nbsp;
+        <input name="deadlineto" size="10" maxlength="10">
+      </td>
+      <td>
+        <small>(YYYY-MM-DD)</small>
+      </td>
+    </tr>
+  [% END %]
+  
 </table>
 
 <hr>