ticket_report

one of the documented procedures in this installation of the ACS
Usage:
ticket_report   db   selection   view   table_def
What it does:
generate a report from an active DB query.
Defined in: /web/philip/tcl/ticket-defs.tcl

Source code:

 
    set i 0
    set html {} 
    while {[ns_db getrow $db $selection]} { 
        set_variables_after_query
        if {![info exists seen($msg_id)]} { 
            set seen($msg_id) 1
            set order($i) $msg_id
            set line($msg_id) "<p><strong><a href=\"issue-view?msg_id=$msg_id\">\#$msg_id $one_line</a></strong><br>Project: <strong>$project_title_long</strong> Feature Area: <strong>$domain_title_long</strong> Status: <strong>$status_long</strong> Creation Date: <strong>$creation_mdy</strong> Severity: <strong>$severity_long</strong><br>"
            if { $view == "full_report" } {
                append chtml($msg_id) "<blockquote>"
                if { $html_p == "f" } { 
                    append chtml($msg_id) [util_convert_plaintext_to_html $message]
                } else { 
                    append chtml($msg_id) $message
                }
                append chtml($msg_id) "<br>-- $user_name &lt;<a href=\"mailto:$email\">$email</a>&gt;</blockquote>"



            }
            incr i
        } 
        if {![empty_string_p $assigned_user_email ]} { 
            lappend ass($msg_id) "<a href=\"mailto:$assigned_user_email\">$assigned_user_email</a>"
        }
    }
    
    if { $i < 1 } { 
        return "<br><em>No data found.</em><br>"
    }

    # ok now for full reports we need to go get the 
    # messages...we can use db since we just finished the query...
    if {$view == "full_report"} {
        set selection [ns_db select $db "select gc.on_what_id, gc.comment_id, gc.client_file_name,
    gc.file_type, gc.original_width, gc.original_height, gc.caption, gc.content, gc.html_p, 
    u.last_name, u.first_names, u.email, u.user_id, 
    to_char(comment_date, 'Month, DD YYYY HH:MI AM') as comment_date_long
  from general_comments gc, users u
  where on_which_table = 'ticket_issues' 
    and u.user_id = gc.user_id 
    and on_what_id in ([join [array names seen] {,}]) 
  order by comment_date asc"]
    
        while {[ns_db getrow $db $selection]} { 
            set_variables_after_query
            append chtml($on_what_id) "[format_general_comment $comment_id $client_file_name $file_type $original_width $original_height $caption $content $html_p]<br> -- $first_names $last_name &lt;<a href=\"mailto:$email\">$email</a>&gt; on $comment_date_long<br>"
        }
    }

    for {set m 0} { $m < $i } { incr m } {
        append html "$line($order($m))" 
        set line($order($m)) {}
        if {[info exists ass($order($m))]} { 
            append html "Assigned to: [join $ass($order($m)) {, }]<br>"
        }
        if {[info exists chtml($order($m))]} { 
            append html "<blockquote>$chtml($order($m))</blockquote>"
            set chtml($order($m)) {}
        }
    }
    return $html


philg@mit.edu