Diff
Not logged in

Differences From:

File src/tkt.c part of check-in [27d2e6e458] - More ticket processing refinements. by drh on 2008-05-28 19:24:58. [view]

To:

File src/tkt.c part of check-in [b3ee50c946] - Implement history display for tickets. by drh on 2008-07-15 19:03:42. [view]

@@ -305,8 +305,12 @@
   if( g.okWrTkt ){
     style_submenu_element("Edit", "Edit The Ticket", "%s/tktedit?name=%T",
         g.zTop, PD("name",""));
   }
+  if( g.okHistory ){
+    style_submenu_element("History", "History Of This Ticket",
+        "%s/tkthistory/%T", g.zTop, PD("name",""));
+  }
   style_header("View Ticket");
   ticket_init();
   initializeVariablesFromDb();
   zScript = ticket_viewpage_code();
@@ -547,5 +551,42 @@
       return zErr;
     }
   }
   return 0;
+}
+
+/*
+** WEBPAGE: tkthistory
+** URL: /tkthistory?name=TICKETUUID
+**
+** Show the complete change history for a single ticket
+*/
+void tkthistory_page(void){
+  Stmt q;
+  char *zTitle;
+  char *zSQL;
+  const char *zUuid;
+  int tagid;
+
+  login_check_credentials();
+  if( !g.okHistory || !g.okRdTkt ){ login_needed(); return; }
+  zUuid = PD("name","");
+  zTitle = mprintf("History Of Ticket %h", zUuid);
+  style_header(zTitle);
+  free(zTitle);
+
+  tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zUuid);
+  if( tagid==0 ){
+    @ No such ticket: %h(zUuid)
+    style_footer();
+    return;
+  }
+  zSQL = mprintf("%s AND event.objid IN "
+                 "  (SELECT rid FROM tagxref WHERE tagid=%d) "
+                 "ORDER BY mtime DESC",
+                 timeline_query_for_www(), tagid);
+  db_prepare(&q, zSQL);
+  free(zSQL);
+  www_print_timeline(&q);
+  db_finalize(&q);
+  style_footer();
 }