<th1>
set q [getParameter q ""]
set st [getParameter st "open"]
set view [getParameter view "list"]
set sort [getParameter sort "priority"]
set wide [getParameter wide ""]
set grp [getParameter group "status"]
set tcol [getParameter tcol "updated"]
set tdir [getParameter tdir "desc"]
set ftype [getParameter tp ""]
set fprio [getParameter pr ""]
set fsev [getParameter sv ""]
set fsub [getParameter sb ""]
set fstat [getParameter fs ""]
set qclean [string trim $q]
set qpat "%$qclean%"
if {$st ne "open" && $st ne "closed" && $st ne "all"} { set st "open" }
if {$view ne "list" && $view ne "table" && $view ne "board"} { set view "list" }
if {$sort ne "priority" && $sort ne "recent"} { set sort "priority" }
if {$grp ne "status" && $grp ne "priority" && $grp ne "subsystem"} { set grp "status" }
if {$tdir ne "asc" && $tdir ne "desc"} { set tdir "desc" }
proc tkt_url {st view sort wide grp qclean ftype fprio fsev fsub fstat tcol tdir} {
set u "reportlist?st=[httpize $st]"
if {$view ne "list"} { set u "$u&view=[httpize $view]" }
if {$sort ne "priority"} { set u "$u&sort=[httpize $sort]" }
if {$wide eq "1"} { set u "$u&wide=1" }
if {$view eq "board" && $grp ne "status"} { set u "$u&group=[httpize $grp]" }
if {$view eq "table" && $tcol ne "updated"} { set u "$u&tcol=[httpize $tcol]&tdir=[httpize $tdir]" }
if {$qclean ne ""} { set u "$u&q=[httpize $qclean]" }
if {$ftype ne ""} { set u "$u&tp=[httpize $ftype]" }
if {$fprio ne ""} { set u "$u&pr=[httpize $fprio]" }
if {$fsev ne ""} { set u "$u&sv=[httpize $fsev]" }
if {$fsub ne ""} { set u "$u&sb=[httpize $fsub]" }
if {$fstat ne ""} { set u "$u&fs=[httpize $fstat]" }
return $u
}
set nopen 0
set nclosed 0
set nall 0
if {[capexpr {r}]} {
query {
SELECT sum(CASE WHEN coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred') THEN 0 ELSE 1 END) AS xo,
sum(CASE WHEN coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred') THEN 1 ELSE 0 END) AS xc,
count(*) AS xa
FROM ticket
} {
if {$xo ne ""} { set nopen $xo }
if {$xc ne ""} { set nclosed $xc }
if {$xa ne ""} { set nall $xa }
}
}
set shellCls "tkt-shell"
if {$wide eq "1"} { set shellCls "tkt-shell tkt-wide" }
html "<div class='$shellCls' data-tkt-page='reportlist'>\n"
</th1>
<div class="tkt-head-bar">
<nav class="tkt-seg" aria-label="Ticket state">
<th1>
set u_open [tkt_url open $view $sort $wide $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir]
set u_cls [tkt_url closed $view $sort $wide $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir]
set u_all [tkt_url all $view $sort $wide $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir]
set c_o ""; set c_c ""; set c_a ""
if {$st eq "open"} { set c_o " is-active" }
if {$st eq "closed"} { set c_c " is-active" }
if {$st eq "all"} { set c_a " is-active" }
html "<a class='$c_o' href='$u_open'><svg class='tkt-state-open' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><circle cx='12' cy='12' r='2.5' fill='currentColor'/></svg>Open <span class='tkt-cnt'>[htmlize $nopen]</span></a>\n"
html "<a class='$c_c' href='$u_cls'><svg class='tkt-state-closed' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><path d='M8.5 12.5l2.2 2.2 4.8-5'/></svg>Closed <span class='tkt-cnt'>[htmlize $nclosed]</span></a>\n"
html "<a class='$c_a' href='$u_all'>All <span class='tkt-cnt'>[htmlize $nall]</span></a>\n"
</th1>
</nav>
<div class="tkt-head-tools">
<nav class="tkt-seg" aria-label="Display mode">
<th1>
set u_vl [tkt_url $st list $sort $wide $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir]
set u_vt [tkt_url $st table $sort $wide $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir]
set u_vb [tkt_url $st board $sort $wide $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir]
set vl ""; set vt ""; set vb ""
if {$view eq "list"} { set vl " is-active" }
if {$view eq "table"} { set vt " is-active" }
if {$view eq "board"} { set vb " is-active" }
html "<a class='$vl' href='$u_vl'>list</a>\n"
html "<a class='$vt' href='$u_vt'>table</a>\n"
html "<a class='$vb' href='$u_vb'>board</a>\n"
</th1>
</nav>
<nav class="tkt-seg" aria-label="Sort order">
<th1>
set u_sp [tkt_url $st $view priority $wide $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir]
set u_sr [tkt_url $st $view recent $wide $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir]
set sp ""; set sr ""
if {$sort eq "priority"} { set sp " is-active" }
if {$sort eq "recent"} { set sr " is-active" }
html "<a class='$sp' href='$u_sp'>priority</a>\n"
html "<a class='$sr' href='$u_sr'>recent</a>\n"
</th1>
</nav>
<th1>
set nextWide "1"
set wideCls "tkt-btn"
set wideTitle "Use wider layout"
if {$wide eq "1"} {
set nextWide ""
set wideCls "tkt-btn is-active"
set wideTitle "Back to reading width"
}
set u_w [tkt_url $st $view $sort $nextWide $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir]
html "<a class='$wideCls' href='$u_w' title='$wideTitle' aria-label='$wideTitle'><svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' aria-hidden='true'><path d='M4 9V5h4M20 9V5h-4M4 15v4h4M20 15v4h-4'/></svg></a>\n"
if {[capexpr {n}]} {
html "<a class='tkt-btn tkt-btn-primary' href='tktnew'><svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><path d='M12 5v14M5 12h14'/></svg>New ticket</a>\n"
}
</th1>
</div>
</div>
<form class="tkt-toolbar" method="get" action="reportlist">
<label class="tkt-search" aria-label="Filter tickets">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg>
<input type="text" name="q" value="$<q>" placeholder="Filter title, subsystem, hash...">
</label>
<input type="hidden" name="st" value="$<st>">
<th1>
if {$view ne "list"} { html "<input type='hidden' name='view' value='[htmlize $view]'>" }
if {$sort ne "priority"} { html "<input type='hidden' name='sort' value='[htmlize $sort]'>" }
if {$wide eq "1"} { html "<input type='hidden' name='wide' value='1'>" }
if {$grp ne "status"} { html "<input type='hidden' name='group' value='[htmlize $grp]'>" }
if {$ftype ne ""} { html "<input type='hidden' name='tp' value='[htmlize $ftype]'>" }
if {$fprio ne ""} { html "<input type='hidden' name='pr' value='[htmlize $fprio]'>" }
if {$fsev ne ""} { html "<input type='hidden' name='sv' value='[htmlize $fsev]'>" }
if {$fsub ne ""} { html "<input type='hidden' name='sb' value='[htmlize $fsub]'>" }
if {$fstat ne ""} { html "<input type='hidden' name='fs' value='[htmlize $fstat]'>" }
</th1>
<button type="submit" class="tkt-btn">Filter</button>
</form>
<th1>
if {[capexpr {r}]} {
html "<form class='tkt-facets' method='get' action='reportlist' data-tkt-auto-submit='1'>\n"
html "<input type='hidden' name='st' value='[htmlize $st]'>\n"
if {$view ne "list"} { html "<input type='hidden' name='view' value='[htmlize $view]'>\n" }
if {$sort ne "priority"} { html "<input type='hidden' name='sort' value='[htmlize $sort]'>\n" }
if {$wide eq "1"} { html "<input type='hidden' name='wide' value='1'>\n" }
if {$grp ne "status"} { html "<input type='hidden' name='group' value='[htmlize $grp]'>\n" }
if {$qclean ne ""} { html "<input type='hidden' name='q' value='[htmlize $qclean]'>\n" }
set cls_tp "tkt-facet"; if {$ftype ne ""} { set cls_tp "tkt-facet is-on" }
html "<label class='$cls_tp'><span>type</span><select name='tp'><option value=''>any</option>"
query {SELECT DISTINCT type AS v, replace(type,'_',' ') AS lbl FROM ticket WHERE length(type)>0 ORDER BY type} {
set sel ""; if {$v eq $ftype} { set sel " selected" }
html "<option value='[htmlize $v]'$sel>[htmlize $lbl]</option>"
}
html "</select></label>\n"
set cls_pr "tkt-facet"; if {$fprio ne ""} { set cls_pr "tkt-facet is-on" }
html "<label class='$cls_pr'><span>priority</span><select name='pr'><option value=''>any</option>"
query {
SELECT DISTINCT priority AS v FROM ticket WHERE length(priority)>0
ORDER BY CASE priority WHEN 'Immediate' THEN 1 WHEN 'High' THEN 2 WHEN 'Medium' THEN 3 WHEN 'Low' THEN 4 WHEN 'Zero' THEN 5 ELSE 9 END, priority
} {
set sel ""; if {$v eq $fprio} { set sel " selected" }
html "<option value='[htmlize $v]'$sel>[htmlize $v]</option>"
}
html "</select></label>\n"
set cls_sv "tkt-facet"; if {$fsev ne ""} { set cls_sv "tkt-facet is-on" }
html "<label class='$cls_sv'><span>severity</span><select name='sv'><option value=''>any</option>"
query {
SELECT DISTINCT severity AS v FROM ticket WHERE length(severity)>0
ORDER BY CASE severity WHEN 'Critical' THEN 1 WHEN 'Severe' THEN 2 WHEN 'Important' THEN 3 WHEN 'Minor' THEN 4 WHEN 'Cosmetic' THEN 5 ELSE 9 END, severity
} {
set sel ""; if {$v eq $fsev} { set sel " selected" }
html "<option value='[htmlize $v]'$sel>[htmlize $v]</option>"
}
html "</select></label>\n"
set cls_sb "tkt-facet"; if {$fsub ne ""} { set cls_sb "tkt-facet is-on" }
html "<label class='$cls_sb'><span>subsystem</span><select name='sb'><option value=''>any</option>"
query {SELECT DISTINCT subsystem AS v FROM ticket WHERE length(subsystem)>0 ORDER BY subsystem} {
set sel ""; if {$v eq $fsub} { set sel " selected" }
html "<option value='[htmlize $v]'$sel>[htmlize $v]</option>"
}
html "</select></label>\n"
set cls_fs "tkt-facet"; if {$fstat ne ""} { set cls_fs "tkt-facet is-on" }
html "<label class='$cls_fs'><span>status</span><select name='fs'><option value=''>any</option>"
query {SELECT DISTINCT status AS v FROM ticket WHERE length(status)>0 ORDER BY status} {
set sel ""; if {$v eq $fstat} { set sel " selected" }
html "<option value='[htmlize $v]'$sel>[htmlize $v]</option>"
}
html "</select></label>\n"
html "<noscript><button type='submit' class='tkt-btn'>Apply</button></noscript>\n"
if {$qclean ne "" || $ftype ne "" || $fprio ne "" || $fsev ne "" || $fsub ne "" || $fstat ne ""} {
set u_clr [tkt_url $st $view $sort $wide $grp "" "" "" "" "" "" $tcol $tdir]
html "<a class='tkt-clear-btn' href='$u_clr'>Clear filters</a>\n"
}
html "</form>\n"
set dom_type ""
set dom_prio ""
set dom_stat ""
set nmatch 0
if {$view eq "list"} {
query {
SELECT count(*) AS nm FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean='' OR t.title LIKE $qpat OR coalesce(t.subsystem,'') LIKE $qpat OR coalesce(t.type,'') LIKE $qpat OR t.tkt_uuid LIKE $qpat)
} {
set nmatch $nm
}
if {$nmatch >= 5} {
set thresh [expr {($nmatch * 7 + 9) / 10}]
query {
SELECT t.type AS dv, count(*) AS dc FROM ticket t
WHERE length(t.type)>0
AND (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean='' OR t.title LIKE $qpat OR coalesce(t.subsystem,'') LIKE $qpat OR coalesce(t.type,'') LIKE $qpat OR t.tkt_uuid LIKE $qpat)
GROUP BY t.type ORDER BY dc DESC LIMIT 1
} {
if {$dc >= $thresh} { set dom_type $dv }
}
query {
SELECT t.priority AS dv, count(*) AS dc FROM ticket t
WHERE length(t.priority)>0
AND (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean='' OR t.title LIKE $qpat OR coalesce(t.subsystem,'') LIKE $qpat OR coalesce(t.type,'') LIKE $qpat OR t.tkt_uuid LIKE $qpat)
GROUP BY t.priority ORDER BY dc DESC LIMIT 1
} {
if {$dc >= $thresh} { set dom_prio $dv }
}
query {
SELECT coalesce(t.status,'Open') AS dv, count(*) AS dc FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean='' OR t.title LIKE $qpat OR coalesce(t.subsystem,'') LIKE $qpat OR coalesce(t.type,'') LIKE $qpat OR t.tkt_uuid LIKE $qpat)
GROUP BY dv ORDER BY dc DESC LIMIT 1
} {
if {$dc >= $thresh} { set dom_stat $dv }
}
}
}
set shown 0
if {$view eq "list"} {
html "<div class='tkt-list'>\n"
query {
SELECT substr(t.tkt_uuid,1,10) AS xid,
coalesce(t.title,'(untitled)') AS xtitle,
coalesce(t.status,'Open') AS xstatus,
coalesce(t.type,'') AS xtype,
replace(coalesce(t.type,''),'_',' ') AS xtypelbl,
coalesce(t.priority,'') AS xprio,
coalesce(t.severity,'') AS xsev,
coalesce(t.subsystem,'') AS xsub,
datetime(t.tkt_mtime, toLocal()) AS xmod,
(SELECT count(*) FROM ticketchng c
WHERE c.tkt_id=t.tkt_id AND length(c.icomment)>0) AS xmsgs,
(SELECT count(*) FROM backlink b
WHERE b.srctype=0 AND b.target=substr(t.tkt_uuid,1,10)) AS xcis
FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR t.tkt_uuid LIKE $qpat)
ORDER BY
CASE WHEN $sort='priority' THEN
CASE t.priority WHEN 'Immediate' THEN 1 WHEN 'High' THEN 2 WHEN 'Medium' THEN 3 WHEN 'Low' THEN 4 WHEN 'Zero' THEN 5 ELSE 6 END
ELSE 0 END ASC,
CASE WHEN $sort='priority' THEN
CASE t.severity WHEN 'Critical' THEN 1 WHEN 'Severe' THEN 2 WHEN 'Important' THEN 3 WHEN 'Minor' THEN 4 WHEN 'Cosmetic' THEN 5 ELSE 6 END
ELSE 0 END ASC,
t.tkt_mtime DESC
LIMIT 200
} {
set shown [expr {$shown + 1}]
set icoCls "tkt-state-open"
set icoSvg "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><circle cx='12' cy='12' r='2.5' fill='currentColor'/></svg>"
if {$xstatus eq "Review"} {
set icoCls "tkt-state-review"
set icoSvg "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><path d='M12 8v4l3 2'/></svg>"
} elseif {$xstatus eq "Fixed" || $xstatus eq "Tested" || $xstatus eq "Closed" || $xstatus eq "Deferred"} {
set icoCls "tkt-state-closed"
set icoSvg "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><path d='M8.5 12.5l2.2 2.2 4.8-5'/></svg>"
}
html "<div class='tkt-row'>\n"
html "<span class='tkt-state-ico $icoCls' title='[htmlize $xstatus]'>$icoSvg</span>\n"
html "<div class='tkt-row-main'>\n"
html "<div class='tkt-row-titleline'>"
html "<a class='tkt-row-title' href='tktview/[httpize $xid]'>[htmlize $xtitle]</a>"
if {$xprio ne "" && $xprio ne $dom_prio} {
if {$xprio eq "Immediate" || $xprio eq "High"} {
html "<span class='tkt-tag tkt-tag-crit'>[htmlize $xprio]</span>"
} else {
html "<span class='tkt-tag'>[htmlize $xprio]</span>"
}
}
if {$xsub ne ""} {
html "<span class='tkt-tag'>[htmlize $xsub]</span>"
}
if {$xstatus ne "Open" && $xstatus ne "" && $xstatus ne $dom_stat} {
set scls "tkt-tag"
if {$xstatus eq "Review"} { set scls "tkt-tag tkt-tag-warn" }
if {$xstatus eq "Fixed" || $xstatus eq "Tested"} { set scls "tkt-tag tkt-tag-ok" }
html "<span class='$scls'>[htmlize $xstatus]</span>"
}
if {$xtype ne "" && $xtype ne $dom_type} {
html "<span class='tkt-tag'>[htmlize $xtypelbl]</span>"
}
html "</div>\n"
html "<div class='tkt-row-meta'>"
html "<code>[htmlize $xid]</code>"
if {$xtypelbl ne ""} { html "<span>[htmlize $xtypelbl]</span>" }
if {$xsev ne ""} { html "<span>[htmlize $xsev]</span>" }
html "<span>Updated [htmlize $xmod]</span>"
html "</div>\n"
html "</div>\n"
html "<div class='tkt-row-right'>"
if {$xmsgs > 0} { html "<span>[htmlize $xmsgs] msg</span>" }
if {$xcis > 0} { html "<span>[htmlize $xcis] ci</span>" }
html "</div>\n"
html "</div>\n"
}
if {$shown == 0} {
html "<div class='tkt-empty'>No tickets match this filter. Try <a href='reportlist?st=all'>All tickets</a> or clear the filters.</div>\n"
}
html "</div>\n"
} elseif {$view eq "table"} {
html "<div class='tkt-tw'><table class='tkt-table'><thead><tr>"
set cols {id ID title Title status Status type Type priority Priority subsystem Subsystem updated Updated}
foreach {ck clbl} $cols {
set ndir "asc"
set mark ""
if {$tcol eq $ck} {
if {$tdir eq "asc"} { set ndir "desc"; set mark " (asc)" } else { set ndir "asc"; set mark " (desc)" }
}
set u_col [tkt_url $st table $sort $wide $grp $qclean $ftype $fprio $fsev $fsub $fstat $ck $ndir]
html "<th><a href='$u_col'>$clbl$mark</a></th>"
}
html "</tr></thead><tbody>\n"
query {
SELECT substr(t.tkt_uuid,1,10) AS xid,
coalesce(t.title,'(untitled)') AS xtitle,
coalesce(t.status,'Open') AS xstatus,
replace(coalesce(t.type,''),'_',' ') AS xtypelbl,
coalesce(t.priority,'') AS xprio,
coalesce(t.subsystem,'') AS xsub,
datetime(t.tkt_mtime, toLocal()) AS xmod
FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR t.tkt_uuid LIKE $qpat)
ORDER BY
CASE WHEN $tcol='id' AND $tdir='asc' THEN t.tkt_uuid END ASC,
CASE WHEN $tcol='id' AND $tdir='desc' THEN t.tkt_uuid END DESC,
CASE WHEN $tcol='title' AND $tdir='asc' THEN lower(t.title) END ASC,
CASE WHEN $tcol='title' AND $tdir='desc' THEN lower(t.title) END DESC,
CASE WHEN $tcol='status' AND $tdir='asc' THEN t.status END ASC,
CASE WHEN $tcol='status' AND $tdir='desc' THEN t.status END DESC,
CASE WHEN $tcol='type' AND $tdir='asc' THEN t.type END ASC,
CASE WHEN $tcol='type' AND $tdir='desc' THEN t.type END DESC,
CASE WHEN $tcol='priority' AND $tdir='asc' THEN
CASE t.priority WHEN 'Immediate' THEN 1 WHEN 'High' THEN 2 WHEN 'Medium' THEN 3 WHEN 'Low' THEN 4 WHEN 'Zero' THEN 5 ELSE 6 END
END ASC,
CASE WHEN $tcol='priority' AND $tdir='desc' THEN
CASE t.priority WHEN 'Immediate' THEN 1 WHEN 'High' THEN 2 WHEN 'Medium' THEN 3 WHEN 'Low' THEN 4 WHEN 'Zero' THEN 5 ELSE 6 END
END DESC,
CASE WHEN $tcol='subsystem' AND $tdir='asc' THEN t.subsystem END ASC,
CASE WHEN $tcol='subsystem' AND $tdir='desc' THEN t.subsystem END DESC,
CASE WHEN $tcol='updated' AND $tdir='asc' THEN t.tkt_mtime END ASC,
t.tkt_mtime DESC
LIMIT 200
} {
set shown [expr {$shown + 1}]
set icoCls "tkt-state-open"
set icoSvg "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><circle cx='12' cy='12' r='2.5' fill='currentColor'/></svg>"
if {$xstatus eq "Review"} {
set icoCls "tkt-state-review"
set icoSvg "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><path d='M12 8v4l3 2'/></svg>"
} elseif {$xstatus eq "Fixed" || $xstatus eq "Tested" || $xstatus eq "Closed" || $xstatus eq "Deferred"} {
set icoCls "tkt-state-closed"
set icoSvg "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' aria-hidden='true'><circle cx='12' cy='12' r='8'/><path d='M8.5 12.5l2.2 2.2 4.8-5'/></svg>"
}
html "<tr>"
html "<td class='c-id'><span class='tkt-state-ico $icoCls' title='[htmlize $xstatus]'>$icoSvg</span><a href='tktview/[httpize $xid]'>[htmlize $xid]</a></td>"
html "<td class='c-title'><a href='tktview/[httpize $xid]'>[htmlize $xtitle]</a></td>"
html "<td>[htmlize $xstatus]</td>"
html "<td class='c-muted'>[htmlize $xtypelbl]</td>"
html "<td>[htmlize $xprio]</td>"
html "<td class='c-muted'>[htmlize $xsub]</td>"
html "<td class='c-muted'>[htmlize $xmod]</td>"
html "</tr>\n"
}
if {$shown == 0} {
html "<tr><td colspan='7' class='tkt-empty'>No tickets match this filter.</td></tr>\n"
}
html "</tbody></table></div>\n"
} else {
html "<form class='tkt-board-bar' method='get' action='reportlist' data-tkt-auto-submit='1'>\n"
html "<input type='hidden' name='st' value='[htmlize $st]'>\n"
html "<input type='hidden' name='view' value='board'>\n"
if {$sort ne "priority"} { html "<input type='hidden' name='sort' value='[htmlize $sort]'>\n" }
if {$wide eq "1"} { html "<input type='hidden' name='wide' value='1'>\n" }
if {$qclean ne ""} { html "<input type='hidden' name='q' value='[htmlize $qclean]'>\n" }
if {$ftype ne ""} { html "<input type='hidden' name='tp' value='[htmlize $ftype]'>\n" }
if {$fprio ne ""} { html "<input type='hidden' name='pr' value='[htmlize $fprio]'>\n" }
if {$fsev ne ""} { html "<input type='hidden' name='sv' value='[htmlize $fsev]'>\n" }
if {$fsub ne ""} { html "<input type='hidden' name='sb' value='[htmlize $fsub]'>\n" }
if {$fstat ne ""} { html "<input type='hidden' name='fs' value='[htmlize $fstat]'>\n" }
html "<label class='tkt-facet'><span>columns</span><select name='group'>"
foreach gopt {status priority subsystem} {
set gsel ""; if {$grp eq $gopt} { set gsel " selected" }
html "<option value='$gopt'$gsel>$gopt</option>"
}
html "</select></label><noscript><button type='submit' class='tkt-btn'>Apply</button></noscript>"
if {[capexpr {w}]} {
html "<span class='tkt-help'>Drag cards between columns or open Move on any card.</span>"
}
html "</form>\n"
html "<div class='tkt-moved-banner' id='tkt-moved-banner' hidden role='status'></div>\n"
set colList {Open Review Fixed Closed}
if {$grp eq "priority"} {
set colList {Immediate High Medium Low Zero}
} elseif {$grp eq "subsystem"} {
set colList {}
query {SELECT DISTINCT subsystem AS sv FROM ticket WHERE length(subsystem)>0 ORDER BY subsystem LIMIT 8} {
lappend colList $sv
}
if {[llength $colList] == 0} { set colList {{(none)}} }
}
set canWrite [capexpr {w}]
html "<div class='tkt-board' data-tkt-board='1' data-tkt-group='[htmlize $grp]' data-tkt-writable='$canWrite'>\n"
foreach colVal $colList {
set colCnt 0
query {
SELECT count(*) AS nc
FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR t.tkt_uuid LIKE $qpat)
AND (($grp='status' AND coalesce(t.status,'Open')=$colVal)
OR ($grp='priority' AND coalesce(t.priority,'')=$colVal)
OR ($grp='subsystem' AND coalesce(t.subsystem,'(none)')=$colVal))
} {
set colCnt $nc
}
html "<section class='tkt-col' data-drop-col='[htmlize $colVal]'>\n"
html "<div class='tkt-col-hdr'><span class='tkt-col-hdr-l'>[htmlize $colVal] <span class='tkt-col-cnt'>[htmlize $colCnt]</span></span></div>\n"
set colRendered 0
query {
SELECT substr(t.tkt_uuid,1,10) AS xid,
coalesce(t.title,'(untitled)') AS xtitle,
coalesce(t.status,'Open') AS xstatus,
coalesce(t.priority,'') AS xprio,
coalesce(t.subsystem,'') AS xsub
FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred')))
AND ($ftype='' OR t.type=$ftype)
AND ($fprio='' OR t.priority=$fprio)
AND ($fsev='' OR t.severity=$fsev)
AND ($fsub='' OR t.subsystem=$fsub)
AND ($fstat='' OR t.status=$fstat)
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR t.tkt_uuid LIKE $qpat)
AND (($grp='status' AND coalesce(t.status,'Open')=$colVal)
OR ($grp='priority' AND coalesce(t.priority,'')=$colVal)
OR ($grp='subsystem' AND coalesce(t.subsystem,'(none)')=$colVal))
ORDER BY
CASE WHEN $sort='priority' THEN
CASE t.priority WHEN 'Immediate' THEN 1 WHEN 'High' THEN 2 WHEN 'Medium' THEN 3 WHEN 'Low' THEN 4 WHEN 'Zero' THEN 5 ELSE 6 END
ELSE 0 END ASC,
t.tkt_mtime DESC
LIMIT 60
} {
set colRendered [expr {$colRendered + 1}]
set shown [expr {$shown + 1}]
set dragAttr ""
if {$canWrite} { set dragAttr " draggable='true'" }
html "<article class='tkt-bcard' data-card-id='[htmlize $xid]'$dragAttr>"
html "<a class='tkt-bcard-title' href='tktview/[httpize $xid]'>[htmlize $xtitle]</a>"
if {($grp ne "priority" && $xprio ne "") || ($grp ne "subsystem" && $xsub ne "")} {
html "<div class='tkt-bcard-tags'>"
if {$grp ne "priority" && $xprio ne ""} {
set pcls "tkt-tag"
if {$xprio eq "Immediate" || $xprio eq "High"} { set pcls "tkt-tag tkt-tag-crit" }
html "<span class='$pcls'>[htmlize $xprio]</span>"
}
if {$grp ne "subsystem" && $xsub ne ""} {
html "<span class='tkt-tag'>[htmlize $xsub]</span>"
}
html "</div>"
}
html "<div class='tkt-bcard-foot'><span>[htmlize $xid]</span>"
if {$canWrite} {
html "<details class='tkt-mv-wrap'><summary class='tkt-mv-btn'>Move</summary><div class='tkt-mv-menu'>"
foreach dst $colList {
if {$dst ne $colVal && $dst ne "(none)"} {
html "<form method='post' action='tktedit/[httpize $xid]' data-tkt-move-form='1' data-tkt-card='[htmlize $xid]' data-tkt-from='[htmlize $colVal]' data-tkt-to='[htmlize $dst]'>"
insertCsrf
html "<input type='hidden' name='submit' value='1'>"
html "<input type='hidden' name='[htmlize $grp]' value='[htmlize $dst]'>"
html "<button type='submit'>[htmlize $dst]</button></form>"
}
}
html "</div></details>"
}
html "</div></article>\n"
}
if {$colRendered == 0} {
html "<div class='tkt-empty tkt-col-empty'>No tickets</div>\n"
}
html "</section>\n"
}
html "</div>\n"
if {$canWrite} {
html "<form id='tkt-board-csrf' hidden>"
insertCsrf
html "</form>\n"
}
}
html "<div class='tkt-count-bar'><span>Showing $shown ticket"
if {$shown != 1} { html "s" }
html "</span>"
if {$qclean ne "" || $st ne "open" || $ftype ne "" || $fprio ne "" || $fsev ne "" || $fsub ne "" || $fstat ne ""} {
html "<a href='reportlist'>Reset filters</a>"
}
html "</div>\n"
}
</th1>
<details class="tkt-drawer">
<summary>Saved SQL reports</summary>
<ol>
<th1>html $report_items</th1>
</ol>
<div class="tkt-drawer-actions">
<th1>
if {[capexpr {t}]} {
html "<a href='rptnew'>New report format</a>"
}
if {[capexpr {q}]} {
html "<a href='modreq'>Pending moderation requests</a>"
}
</th1>
</div>
</details>
</div>