<th1>
set q [getParameter q ""]
set st [getParameter st "open"]
set view [getParameter view "list"]
set sortParam [getParameter sort ""]
set grpParam [getParameter group ""]
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 fscope [getParameter scope ""]
set fas [getParameter as ""]
set fage [getParameter age ""]
set pgParam [getParameter pg "1"]
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 {$tdir ne "asc" && $tdir ne "desc"} { set tdir "desc" }
if {$fscope ne "" && $fscope ne "mine" && $fscope ne "involved" && $fscope ne "unassigned"} { set fscope "" }
if {$fage ne "" && $fage ne "30" && $fage ne "180"} { set fage "" }
set pg 1
if {[regexp {^[1-9][0-9]*$} $pgParam]} { set pg [expr {$pgParam + 0}] }
if {$pg > 500} { set pg 500 }
set offset [expr {($pg - 1) * 200}]
set hasLogin 0
set curUser ""
if {[info exists login]} {
if {$login ne "" && $login ne "nobody" && $login ne "anonymous"} {
set hasLogin 1
set curUser $login
}
}
set hasAssignee 0
set hasSubmitter 0
set hasClosedate 0
if {[capexpr {r}]} {
query -nocomplain {SELECT count(assignee) AS _x FROM ticket} { set hasAssignee 1 }
query -nocomplain {SELECT count(submitter) AS _x FROM ticket} { set hasSubmitter 1 }
query -nocomplain {SELECT count(closedate) AS _x FROM ticket} { set hasClosedate 1 }
}
if {!$hasAssignee} {
if {$fscope eq "mine" || $fscope eq "unassigned"} { set fscope "" }
set fas ""
}
if {!$hasLogin} {
if {$fscope eq "mine" || $fscope eq "involved"} { set fscope "" }
}
set nopen 0
set nclosed 0
set nall 0
set nact30 0
set npend 0
set nunassigned 0
set nmine 0
set ninvolved 0
if {[capexpr {r}]} {
query {
SELECT sum(CASE WHEN coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected') THEN 0 ELSE 1 END) AS xo,
sum(CASE WHEN coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected') THEN 1 ELSE 0 END) AS xc,
count(*) AS xa,
sum(CASE WHEN coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')
AND julianday('now') - tkt_mtime <= 30 THEN 1 ELSE 0 END) AS xact,
sum(CASE WHEN status='Pending' THEN 1 ELSE 0 END) AS xpend
FROM ticket
} {
if {$xo ne ""} { set nopen $xo }
if {$xc ne ""} { set nclosed $xc }
if {$xa ne ""} { set nall $xa }
if {$xact ne ""} { set nact30 $xact }
if {$xpend ne ""} { set npend $xpend }
}
if {$hasAssignee} {
query -nocomplain {
SELECT sum(CASE WHEN coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')
AND coalesce(assignee,'') IN ('','nobody') THEN 1 ELSE 0 END) AS xun,
sum(CASE WHEN coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')
AND assignee = user() THEN 1 ELSE 0 END) AS xmine
FROM ticket
} {
if {$xun ne ""} { set nunassigned $xun }
if {$xmine ne ""} { set nmine $xmine }
}
}
if {$hasLogin} {
if {$hasAssignee && $hasSubmitter} {
query -nocomplain {
SELECT count(*) AS xinv FROM ticket t
WHERE coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')
AND (t.assignee = user() OR t.submitter = user()
OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))
} {
if {$xinv ne ""} { set ninvolved $xinv }
}
} elseif {$hasAssignee} {
query -nocomplain {
SELECT count(*) AS xinv FROM ticket t
WHERE coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')
AND (t.assignee = user()
OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))
} {
if {$xinv ne ""} { set ninvolved $xinv }
}
} else {
query {
SELECT count(*) AS xinv FROM ticket t
WHERE coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')
AND EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user())
} {
if {$xinv ne ""} { set ninvolved $xinv }
}
}
}
}
set defaultSort "priority"
if {$nopen > 100} { set defaultSort "recent" }
set sort $sortParam
if {$sort ne "priority" && $sort ne "recent"} { set sort $defaultSort }
set defaultGrp "status"
if {$hasAssignee && $st eq "open"} { set defaultGrp "assignee" }
set grp $grpParam
if {$grp ne "status" && $grp ne "priority" && $grp ne "subsystem" && !($hasAssignee && $grp eq "assignee")} {
set grp $defaultGrp
}
proc tkt_url {st view sort grp qclean ftype fprio fsev fsub fstat tcol tdir fscope fas fage pg defaultSort defaultGrp} {
set u "reportlist?st=[httpize $st]"
if {$view ne "list"} { set u "$u&view=[httpize $view]" }
if {$sort ne $defaultSort} { set u "$u&sort=[httpize $sort]" }
if {$view eq "board" && $grp ne $defaultGrp} { 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]" }
if {$fscope ne ""} { set u "$u&scope=[httpize $fscope]" }
if {$fas ne ""} { set u "$u&as=[httpize $fas]" }
if {$fage ne ""} { set u "$u&age=[httpize $fage]" }
if {$pg > 1} { set u "$u&pg=$pg" }
return $u
}
proc tkt_state_svg {kind extraCls} {
set ca ""
if {$extraCls ne ""} { set ca " class='$extraCls'" }
if {$kind eq "review"} {
return "<svg$ca viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.65' aria-hidden='true'><rect x='2.5' y='2.5' width='11' height='11' rx='2.5'/><path d='M5.5 8h5'/></svg>"
}
if {$kind eq "closed"} {
return "<svg$ca viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.65' aria-hidden='true'><rect x='2.5' y='2.5' width='11' height='11' rx='2.5'/><path d='M5.2 8.2l1.9 1.9 3.8-4'/></svg>"
}
return "<svg$ca viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.65' aria-hidden='true'><rect x='2.5' y='2.5' width='11' height='11' rx='2.5'/></svg>"
}
proc tkt_chev_svg {} {
return "<svg viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.8' aria-hidden='true'><path d='M4.5 6.2L8 9.8l3.5-3.6'/></svg>"
}
proc tkt_note_svg {} {
return "<svg viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' aria-hidden='true'><path d='M2.5 3.5h11v7.5H6.8L3.5 13.5V11h-1z'/></svg>"
}
proc tkt_ci_svg {} {
return "<svg viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' aria-hidden='true'><circle cx='8' cy='8' r='2.6'/><path d='M1.5 8h3.9M10.6 8h3.9'/></svg>"
}
html "<div class='tkt-shell' 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 $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set u_cls [tkt_url closed $view $sort $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir "" $fas $fage 1 $defaultSort $defaultGrp]
set u_all [tkt_url all $view $sort $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
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'>[tkt_state_svg open tkt-state-open]Open <span class='tkt-cnt'>[htmlize $nopen]</span></a>\n"
html "<a class='$c_c' href='$u_cls'>[tkt_state_svg closed tkt-state-closed]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 $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set u_vt [tkt_url $st table $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set u_vb [tkt_url $st board $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
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 $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set u_sr [tkt_url $st $view recent $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
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>
<details class="tkt-rpt-pop" data-tkt-popover="1">
<summary class="tkt-btn">Reports</summary>
<div class="tkt-rpt-menu">
<div class="tkt-rpt-hdr">Saved SQL reports</div>
<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</a>"
}
</th1>
</div>
</div>
</details>
<th1>
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>
<th1>
if {[capexpr {r}] && $nall > 0} {
html "<nav class='tkt-queues' aria-label='Quick queues'>\n"
if {$hasLogin && $hasAssignee} {
set nextSc "mine"; set qcls "tkt-qpill"
if {$fscope eq "mine"} { set nextSc ""; set qcls "tkt-qpill is-on" }
set u_qm [tkt_url open $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $nextSc "" $fage 1 $defaultSort $defaultGrp]
html "<a class='$qcls' href='$u_qm'>Mine (@[htmlize $curUser]) <span class='tkt-cnt'>[htmlize $nmine]</span></a>\n"
}
if {$hasLogin} {
set nextSc "involved"; set qcls "tkt-qpill"
if {$fscope eq "involved"} { set nextSc ""; set qcls "tkt-qpill is-on" }
set u_qi [tkt_url open $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $nextSc "" $fage 1 $defaultSort $defaultGrp]
html "<a class='$qcls' href='$u_qi'>Involved <span class='tkt-cnt'>[htmlize $ninvolved]</span></a>\n"
}
if {$hasAssignee} {
set nextSc "unassigned"; set qcls "tkt-qpill"
if {$fscope eq "unassigned"} { set nextSc ""; set qcls "tkt-qpill is-on" }
set u_qu [tkt_url open $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $nextSc "" $fage 1 $defaultSort $defaultGrp]
html "<a class='$qcls' href='$u_qu'>Unassigned <span class='tkt-cnt'>[htmlize $nunassigned]</span></a>\n"
}
set nextAge "30"; set acls "tkt-qpill"
if {$fage eq "30"} { set nextAge ""; set acls "tkt-qpill is-on" }
set u_qa [tkt_url open $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $nextAge 1 $defaultSort $defaultGrp]
html "<a class='$acls' href='$u_qa'>Active 30d <span class='tkt-cnt'>[htmlize $nact30]</span></a>\n"
if {$npend > 0} {
set nextFs "Pending"; set pcls "tkt-qpill"
if {$fstat eq "Pending"} { set nextFs ""; set pcls "tkt-qpill is-on" }
set u_qp [tkt_url open $view $sort $grp $qclean $ftype $fprio $fsev $fsub $nextFs $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='$pcls' href='$u_qp'>Pending <span class='tkt-cnt'>[htmlize $npend]</span></a>\n"
}
html "</nav>\n"
}
</th1>
<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>
<th1>
set sph "Filter title, subsystem, version, hash..."
if {$hasAssignee} { set sph "Filter title, subsystem, assignee, version, hash..." }
html "<input type='search' name='q' value='[htmlize $q]' placeholder='$sph' data-tkt-search='1'>"
if {$qclean ne ""} {
set u_clrq [tkt_url $st $view $sort $grp "" $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-search-clear' href='$u_clrq' aria-label='Clear search' title='Clear search'><svg viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.8' aria-hidden='true'><path d='M4 4l8 8M12 4l-8 8'/></svg></a>"
}
</th1>
</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 $defaultSort} { html "<input type='hidden' name='sort' value='[htmlize $sort]'>" }
if {$grp ne $defaultGrp} { 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]'>" }
if {$fscope ne ""} { html "<input type='hidden' name='scope' value='[htmlize $fscope]'>" }
if {$fas ne ""} { html "<input type='hidden' name='as' value='[htmlize $fas]'>" }
if {$fage ne ""} { html "<input type='hidden' name='age' value='[htmlize $fage]'>" }
</th1>
<button type="submit" class="tkt-btn">Filter</button>
<th1>
set u_fts "tktsrch"
if {$qclean ne ""} { set u_fts "tktsrch?s=[httpize $qclean]" }
html "<a class='tkt-btn' href='$u_fts' title='Full-text search descriptions and comments'>Full-text</a>"
</th1>
</form>
<th1>
if {[capexpr {r}]} {
set stTotal $nall
if {$st eq "open"} { set stTotal $nopen }
if {$st eq "closed"} { set stTotal $nclosed }
html "<div class='tkt-facets' role='group' aria-label='Filter facets'>\n"
if {$hasAssignee} {
set cls_as "tkt-fpop"; set lbl_as "any"
if {$fas eq "__unassigned__"} {
set cls_as "tkt-fpop is-on"; set lbl_as "(unassigned)"
} elseif {$fas ne ""} {
set cls_as "tkt-fpop is-on"; set lbl_as "@$fas"
}
set u_any_as [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope "" $fage 1 $defaultSort $defaultGrp]
set cur_any_as ""; if {$fas eq ""} { set cur_any_as " is-cur" }
set u_un_as [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir "" "__unassigned__" $fage 1 $defaultSort $defaultGrp]
set cur_un_as ""; if {$fas eq "__unassigned__"} { set cur_un_as " is-cur" }
set unStCnt $nunassigned
if {$st ne "open"} {
set unStCnt 0
query -nocomplain {
SELECT count(*) AS xu FROM ticket
WHERE coalesce(assignee,'') IN ('','nobody')
AND (($st='all')
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
} { set unStCnt $xu }
}
html "<details class='$cls_as' data-tkt-popover='1'><summary><span>assignee</span><strong>[htmlize $lbl_as]</strong>[tkt_chev_svg]</summary><div class='tkt-fpop-menu'>\n"
html "<a class='tkt-fpop-item$cur_any_as' href='$u_any_as'><span>any</span><span class='tkt-fpop-cnt'>[htmlize $stTotal]</span></a>\n"
html "<a class='tkt-fpop-item$cur_un_as' href='$u_un_as'><span>(unassigned)</span><span class='tkt-fpop-cnt'>[htmlize $unStCnt]</span></a>\n"
set seen_as 0
query -nocomplain {
SELECT assignee AS v, count(*) AS cnt
FROM ticket
WHERE length(assignee)>0 AND assignee<>'nobody'
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
GROUP BY assignee
ORDER BY cnt DESC, assignee ASC
} {
set cur ""; if {$v eq $fas} { set cur " is-cur"; set seen_as 1 }
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir "" $v $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item$cur' href='$u_v'><span>@[htmlize $v]</span><span class='tkt-fpop-cnt'>[htmlize $cnt]</span></a>\n"
}
if {$fas ne "" && $fas ne "__unassigned__" && !$seen_as} {
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir "" $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item is-cur' href='$u_v'><span>@[htmlize $fas]</span><span class='tkt-fpop-cnt'>0</span></a>\n"
}
html "</div></details>\n"
}
set cls_tp "tkt-fpop"; set lbl_tp "any"
if {$ftype ne ""} {
set cls_tp "tkt-fpop is-on"
set lbl_tp $ftype
query {SELECT replace($ftype,'_',' ') AS lt} { set lbl_tp $lt }
}
set u_any_tp [tkt_url $st $view $sort $grp $qclean "" $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set cur_any_tp ""; if {$ftype eq ""} { set cur_any_tp " is-cur" }
html "<details class='$cls_tp' data-tkt-popover='1'><summary><span>type</span><strong>[htmlize $lbl_tp]</strong>[tkt_chev_svg]</summary><div class='tkt-fpop-menu'>\n"
html "<a class='tkt-fpop-item$cur_any_tp' href='$u_any_tp'><span>any</span><span class='tkt-fpop-cnt'>[htmlize $stTotal]</span></a>\n"
set seen_tp 0
query {
SELECT type AS v, replace(type,'_',' ') AS lbl, count(*) AS cnt
FROM ticket
WHERE length(type)>0
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
GROUP BY type ORDER BY type
} {
set cur ""; if {$v eq $ftype} { set cur " is-cur"; set seen_tp 1 }
set u_v [tkt_url $st $view $sort $grp $qclean $v $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item$cur' href='$u_v'><span>[htmlize $lbl]</span><span class='tkt-fpop-cnt'>[htmlize $cnt]</span></a>\n"
}
if {$ftype ne "" && !$seen_tp} {
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item is-cur' href='$u_v'><span>[htmlize $lbl_tp]</span><span class='tkt-fpop-cnt'>0</span></a>\n"
}
html "</div></details>\n"
set cls_pr "tkt-fpop"; set lbl_pr "any"
if {$fprio ne ""} { set cls_pr "tkt-fpop is-on"; set lbl_pr $fprio }
set u_any_pr [tkt_url $st $view $sort $grp $qclean $ftype "" $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set cur_any_pr ""; if {$fprio eq ""} { set cur_any_pr " is-cur" }
html "<details class='$cls_pr' data-tkt-popover='1'><summary><span>priority</span><strong>[htmlize $lbl_pr]</strong>[tkt_chev_svg]</summary><div class='tkt-fpop-menu'>\n"
html "<a class='tkt-fpop-item$cur_any_pr' href='$u_any_pr'><span>any</span><span class='tkt-fpop-cnt'>[htmlize $stTotal]</span></a>\n"
set seen_pr 0
query {
SELECT priority AS v, count(*) AS cnt FROM ticket
WHERE length(priority)>0
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
GROUP BY priority
ORDER BY CASE
WHEN priority IN ('Immediate','9 Immediate') OR priority GLOB '9*' THEN 1
WHEN priority GLOB '8*' THEN 2
WHEN priority IN ('High','7 High') OR priority GLOB '7*' THEN 3
WHEN priority GLOB '6*' THEN 4
WHEN priority IN ('Medium','5 Medium') OR priority GLOB '5*' THEN 5
WHEN priority GLOB '4*' THEN 6
WHEN priority IN ('Low','3 Low') OR priority GLOB '3*' THEN 7
WHEN priority GLOB '2*' THEN 8
WHEN priority IN ('Zero','1 Zero') OR priority GLOB '1*' THEN 9
ELSE 10 END, priority
} {
set cur ""; if {$v eq $fprio} { set cur " is-cur"; set seen_pr 1 }
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $v $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item$cur' href='$u_v'><span>[htmlize $v]</span><span class='tkt-fpop-cnt'>[htmlize $cnt]</span></a>\n"
}
if {$fprio ne "" && !$seen_pr} {
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item is-cur' href='$u_v'><span>[htmlize $fprio]</span><span class='tkt-fpop-cnt'>0</span></a>\n"
}
html "</div></details>\n"
set cls_sb "tkt-fpop"; set lbl_sb "any"
if {$fsub ne ""} { set cls_sb "tkt-fpop is-on"; set lbl_sb $fsub }
set u_any_sb [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev "" $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set cur_any_sb ""; if {$fsub eq ""} { set cur_any_sb " is-cur" }
html "<details class='$cls_sb' data-tkt-popover='1'><summary><span>subsystem</span><strong>[htmlize $lbl_sb]</strong>[tkt_chev_svg]</summary><div class='tkt-fpop-menu'>\n"
html "<a class='tkt-fpop-item$cur_any_sb' href='$u_any_sb'><span>any</span><span class='tkt-fpop-cnt'>[htmlize $stTotal]</span></a>\n"
set seen_sb 0
query {
SELECT subsystem AS v, count(*) AS cnt FROM ticket
WHERE length(subsystem)>0
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
GROUP BY subsystem ORDER BY subsystem
} {
set cur ""; if {$v eq $fsub} { set cur " is-cur"; set seen_sb 1 }
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $v $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item$cur' href='$u_v'><span>[htmlize $v]</span><span class='tkt-fpop-cnt'>[htmlize $cnt]</span></a>\n"
}
if {$fsub ne "" && !$seen_sb} {
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item is-cur' href='$u_v'><span>[htmlize $fsub]</span><span class='tkt-fpop-cnt'>0</span></a>\n"
}
html "</div></details>\n"
set cls_fs "tkt-fpop"; set lbl_fs "any"
if {$fstat ne ""} { set cls_fs "tkt-fpop is-on"; set lbl_fs $fstat }
set u_any_fs [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set cur_any_fs ""; if {$fstat eq ""} { set cur_any_fs " is-cur" }
html "<details class='$cls_fs' data-tkt-popover='1'><summary><span>status</span><strong>[htmlize $lbl_fs]</strong>[tkt_chev_svg]</summary><div class='tkt-fpop-menu'>\n"
html "<a class='tkt-fpop-item$cur_any_fs' href='$u_any_fs'><span>any</span><span class='tkt-fpop-cnt'>[htmlize $stTotal]</span></a>\n"
set seen_fs 0
query {
SELECT status AS v, count(*) AS cnt FROM ticket
WHERE length(status)>0
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
GROUP BY status ORDER BY status
} {
set cur ""; if {$v eq $fstat} { set cur " is-cur"; set seen_fs 1 }
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $v $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item$cur' href='$u_v'><span>[htmlize $v]</span><span class='tkt-fpop-cnt'>[htmlize $cnt]</span></a>\n"
}
if {$fstat ne "" && !$seen_fs} {
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item is-cur' href='$u_v'><span>[htmlize $fstat]</span><span class='tkt-fpop-cnt'>0</span></a>\n"
}
html "</div></details>\n"
set cls_sv "tkt-fpop"; set lbl_sv "any"
if {$fsev ne ""} { set cls_sv "tkt-fpop is-on"; set lbl_sv $fsev }
set u_any_sv [tkt_url $st $view $sort $grp $qclean $ftype $fprio "" $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
set cur_any_sv ""; if {$fsev eq ""} { set cur_any_sv " is-cur" }
html "<details class='$cls_sv' data-tkt-popover='1'><summary><span>severity</span><strong>[htmlize $lbl_sv]</strong>[tkt_chev_svg]</summary><div class='tkt-fpop-menu'>\n"
html "<a class='tkt-fpop-item$cur_any_sv' href='$u_any_sv'><span>any</span><span class='tkt-fpop-cnt'>[htmlize $stTotal]</span></a>\n"
set seen_sv 0
query {
SELECT severity AS v, count(*) AS cnt FROM ticket
WHERE length(severity)>0
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
GROUP BY severity
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 cur ""; if {$v eq $fsev} { set cur " is-cur"; set seen_sv 1 }
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $v $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item$cur' href='$u_v'><span>[htmlize $v]</span><span class='tkt-fpop-cnt'>[htmlize $cnt]</span></a>\n"
}
if {$fsev ne "" && !$seen_sv} {
set u_v [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item is-cur' href='$u_v'><span>[htmlize $fsev]</span><span class='tkt-fpop-cnt'>0</span></a>\n"
}
html "</div></details>\n"
if {$qclean ne "" || $ftype ne "" || $fprio ne "" || $fsev ne "" || $fsub ne "" || $fstat ne "" || $fscope ne "" || $fas ne "" || $fage ne ""} {
set u_clr [tkt_url $st $view $sort $grp "" "" "" "" "" "" $tcol $tdir "" "" "" 1 $defaultSort $defaultGrp]
html "<a class='tkt-clear-btn' href='$u_clr'>Clear filters</a>\n"
}
html "</div>\n"
set dom_prio ""
set dom_stat ""
set nmatch 0
if {$view eq "list" || $view eq "table"} {
if {$hasAssignee} {
query -nocomplain {
SELECT count(*) AS nm FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fas='' OR ($fas='__unassigned__' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$fas)
AND ($fscope=''
OR ($fscope='mine' AND t.assignee=user())
OR ($fscope='unassigned' AND coalesce(t.assignee,'') IN ('','nobody'))
OR ($fscope='involved' AND (t.assignee=user() OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean='' OR t.title LIKE $qpat OR coalesce(t.subsystem,'') LIKE $qpat OR coalesce(t.type,'') LIKE $qpat OR coalesce(t.assignee,'') LIKE $qpat OR coalesce(t.foundin,'') LIKE $qpat OR t.tkt_uuid LIKE $qpat)
} {
set nmatch $nm
}
} else {
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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fscope='' OR ($fscope='involved' AND EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user())))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean='' OR t.title LIKE $qpat OR coalesce(t.subsystem,'') LIKE $qpat OR coalesce(t.type,'') LIKE $qpat OR coalesce(t.foundin,'') LIKE $qpat OR t.tkt_uuid LIKE $qpat)
} {
set nmatch $nm
}
}
if {$view eq "list" && $nmatch >= 5} {
set thresh [expr {($nmatch * 7 + 9) / 10}]
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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
GROUP BY dv ORDER BY dc DESC LIMIT 1
} {
if {$dc >= $thresh} { set dom_stat $dv }
}
}
}
proc tkt_render_list_row {xid xtitle xstatus xtypelbl xprio xsev xsub xmod_utc xcre_utc xmod_day xmsgs xcis xas xpcue hasAssignee dom_prio dom_stat} {
set icoCls "tkt-state-open"
set icoSvg [tkt_state_svg open ""]
if {$xstatus eq "Review" || $xstatus eq "Pending"} {
set icoCls "tkt-state-review"
set icoSvg [tkt_state_svg review ""]
} elseif {$xstatus eq "Fixed" || $xstatus eq "Tested" || $xstatus eq "Closed" || $xstatus eq "Deferred" || $xstatus eq "Deleted" || $xstatus eq "Rejected"} {
set icoCls "tkt-state-closed"
set icoSvg [tkt_state_svg closed ""]
}
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" || [string match 9* $xprio] || [string match 8* $xprio] || [string match 7* $xprio]} {
html "<span class='tkt-tag tkt-tag-crit'>[htmlize $xprio]</span>"
} else {
html "<span class='tkt-tag'>[htmlize $xprio]</span>"
}
}
if {$xsub ne "" && $xsub ne "None"} {
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" || $xstatus eq "Pending"} { 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 {$xpcue eq "reply"} {
html "<span class='tkt-tag tkt-tag-ok'>reply waiting</span>"
} elseif {$xpcue eq "stale"} {
html "<span class='tkt-tag'>stale >14d</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 "<button type='button' class='tkt-time-btn' data-tkt-time='1' data-tkt-mod='[htmlize $xmod_utc]' data-tkt-cre='[htmlize $xcre_utc]' data-tkt-kind='list' title='Updated [htmlize $xmod_utc] UTC'>Updated [htmlize $xmod_day]</button>"
html "</div>\n"
html "</div>\n"
html "<div class='tkt-row-right'>"
if {$hasAssignee} {
if {$xas eq "" || $xas eq "nobody"} {
html "<span class='tkt-owner is-unassigned'>unassigned</span>"
} else {
html "<span class='tkt-owner'>@[htmlize $xas]</span>"
}
}
if {$xmsgs > 0} {
set mtip "$xmsgs comment"
if {$xmsgs != 1} { set mtip "$xmsgs comments" }
html "<span class='tkt-cnt-slot' title='[htmlize $mtip]'>[tkt_note_svg]<span>[htmlize $xmsgs]</span></span>"
} else {
html "<span class='tkt-cnt-slot'></span>"
}
if {$xcis > 0} {
set ctip "$xcis linked check-in"
if {$xcis != 1} { set ctip "$xcis linked check-ins" }
html "<span class='tkt-cnt-slot is-ci' title='[htmlize $ctip]'>[tkt_ci_svg]<span>[htmlize $xcis]</span></span>"
} else {
html "<span class='tkt-cnt-slot is-ci'></span>"
}
html "</div>\n"
html "</div>\n"
}
set shown 0
if {$view eq "list"} {
html "<div class='tkt-list'>\n"
if {$hasAssignee && $hasClosedate} {
query -nocomplain {
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.severity,'') AS xsev,
coalesce(t.subsystem,'') AS xsub,
coalesce(t.assignee,'') AS xas,
CASE
WHEN t.status='Pending' AND t.closedate IS NOT NULL AND t.closedate<>''
AND julianday(t.tkt_mtime) > julianday(t.closedate) + 0.05 THEN 'reply'
WHEN t.status='Pending' AND julianday('now') - t.tkt_mtime > 14 THEN 'stale'
ELSE '' END AS xpcue,
datetime(t.tkt_mtime) AS xmod_utc,
datetime(t.tkt_ctime) AS xcre_utc,
substr(datetime(t.tkt_mtime),1,10) AS xmod_day,
(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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fas='' OR ($fas='__unassigned__' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$fas)
AND ($fscope=''
OR ($fscope='mine' AND t.assignee=user())
OR ($fscope='unassigned' AND coalesce(t.assignee,'') IN ('','nobody'))
OR ($fscope='involved' AND (t.assignee=user() OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.assignee,'') LIKE $qpat
OR coalesce(t.foundin,'') LIKE $qpat
OR t.tkt_uuid LIKE $qpat)
ORDER BY
CASE WHEN $sort='priority' THEN
CASE
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 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 OFFSET $offset
} {
set shown [expr {$shown + 1}]
tkt_render_list_row $xid $xtitle $xstatus $xtypelbl $xprio $xsev $xsub $xmod_utc $xcre_utc $xmod_day $xmsgs $xcis $xas $xpcue 1 $dom_prio $dom_stat
}
} elseif {$hasAssignee} {
query -nocomplain {
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.severity,'') AS xsev,
coalesce(t.subsystem,'') AS xsub,
coalesce(t.assignee,'') AS xas,
CASE WHEN t.status='Pending' AND julianday('now') - t.tkt_mtime > 14 THEN 'stale' ELSE '' END AS xpcue,
datetime(t.tkt_mtime) AS xmod_utc,
datetime(t.tkt_ctime) AS xcre_utc,
substr(datetime(t.tkt_mtime),1,10) AS xmod_day,
(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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fas='' OR ($fas='__unassigned__' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$fas)
AND ($fscope=''
OR ($fscope='mine' AND t.assignee=user())
OR ($fscope='unassigned' AND coalesce(t.assignee,'') IN ('','nobody'))
OR ($fscope='involved' AND (t.assignee=user() OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.assignee,'') LIKE $qpat
OR coalesce(t.foundin,'') LIKE $qpat
OR t.tkt_uuid LIKE $qpat)
ORDER BY
CASE WHEN $sort='priority' THEN
CASE
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 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 OFFSET $offset
} {
set shown [expr {$shown + 1}]
tkt_render_list_row $xid $xtitle $xstatus $xtypelbl $xprio $xsev $xsub $xmod_utc $xcre_utc $xmod_day $xmsgs $xcis $xas $xpcue 1 $dom_prio $dom_stat
}
} else {
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.severity,'') AS xsev,
coalesce(t.subsystem,'') AS xsub,
datetime(t.tkt_mtime) AS xmod_utc,
datetime(t.tkt_ctime) AS xcre_utc,
substr(datetime(t.tkt_mtime),1,10) AS xmod_day,
(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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fscope='' OR ($fscope='involved' AND EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user())))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.foundin,'') LIKE $qpat
OR t.tkt_uuid LIKE $qpat)
ORDER BY
CASE WHEN $sort='priority' THEN
CASE
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 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 OFFSET $offset
} {
set shown [expr {$shown + 1}]
tkt_render_list_row $xid $xtitle $xstatus $xtypelbl $xprio $xsev $xsub $xmod_utc $xcre_utc $xmod_day $xmsgs $xcis "" "" 0 $dom_prio $dom_stat
}
}
if {$shown == 0} {
set u_clr_e [tkt_url $st $view $sort $grp "" "" "" "" "" "" $tcol $tdir "" "" "" 1 $defaultSort $defaultGrp]
set u_all_q [tkt_url all $view $sort $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir "" $fas "" 1 $defaultSort $defaultGrp]
html "<div class='tkt-empty'>"
if {$qclean ne ""} {
html "No tickets match <strong>[htmlize $qclean]</strong> in this view. "
html "<a href='$u_all_q'>Search all [htmlize $nall] tickets</a>, "
html "<a href='tktsrch?s=[httpize $qclean]'>full-text search descriptions</a>, or "
html "<a href='$u_clr_e'>clear filters</a>."
} else {
html "No tickets match this filter. "
html "<a href='$u_clr_e'>Clear filters</a> or "
html "<a href='reportlist?st=all'>view all [htmlize $nall] tickets</a>."
}
html "</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}
if {$hasAssignee} {
set cols {id ID title Title assignee Assignee 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 $grp $qclean $ftype $fprio $fsev $fsub $fstat $ck $ndir $fscope $fas $fage 1 $defaultSort $defaultGrp]
if {$ck eq "updated"} {
html "<th><a href='$u_col' data-tkt-date-hdr='1' data-tkt-sort-mark='[htmlize $mark]'>$clbl$mark</a></th>"
} else {
html "<th><a href='$u_col'>$clbl$mark</a></th>"
}
}
html "</tr></thead><tbody>\n"
proc tkt_render_table_row {xid xtitle xas xstatus xtypelbl xprio xsub xmod_utc xcre_utc xmod_day hasAssignee} {
set icoCls "tkt-state-open"
set icoSvg [tkt_state_svg open ""]
if {$xstatus eq "Review" || $xstatus eq "Pending"} {
set icoCls "tkt-state-review"
set icoSvg [tkt_state_svg review ""]
} elseif {$xstatus eq "Fixed" || $xstatus eq "Tested" || $xstatus eq "Closed" || $xstatus eq "Deferred" || $xstatus eq "Deleted" || $xstatus eq "Rejected"} {
set icoCls "tkt-state-closed"
set icoSvg [tkt_state_svg closed ""]
}
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>"
if {$hasAssignee} {
if {$xas eq "" || $xas eq "nobody"} {
html "<td class='c-muted c-as'>unassigned</td>"
} else {
html "<td class='c-as' title='@[htmlize $xas]'>@[htmlize $xas]</td>"
}
}
html "<td>[htmlize $xstatus]</td>"
html "<td class='c-muted'>[htmlize $xtypelbl]</td>"
html "<td>[htmlize $xprio]</td>"
html "<td class='c-muted c-sub' title='[htmlize $xsub]'>[htmlize $xsub]</td>"
html "<td class='c-muted'><button type='button' class='tkt-time-btn' data-tkt-time='1' data-tkt-mod='[htmlize $xmod_utc]' data-tkt-cre='[htmlize $xcre_utc]' data-tkt-kind='table' title='Updated [htmlize $xmod_utc] UTC'>[htmlize $xmod_day]</button></td>"
html "</tr>\n"
}
if {$hasAssignee} {
query -nocomplain {
SELECT substr(t.tkt_uuid,1,10) AS xid,
coalesce(t.title,'(untitled)') AS xtitle,
coalesce(t.assignee,'') AS xas,
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) AS xmod_utc,
datetime(t.tkt_ctime) AS xcre_utc,
substr(datetime(t.tkt_mtime),1,10) AS xmod_day
FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fas='' OR ($fas='__unassigned__' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$fas)
AND ($fscope=''
OR ($fscope='mine' AND t.assignee=user())
OR ($fscope='unassigned' AND coalesce(t.assignee,'') IN ('','nobody'))
OR ($fscope='involved' AND (t.assignee=user() OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.assignee,'') LIKE $qpat
OR coalesce(t.foundin,'') 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='assignee' AND $tdir='asc' THEN lower(coalesce(t.assignee,'zzzz')) END ASC,
CASE WHEN $tcol='assignee' AND $tdir='desc' THEN lower(coalesce(t.assignee,'')) 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
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 END
END ASC,
CASE WHEN $tcol='priority' AND $tdir='desc' THEN
CASE
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 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 OFFSET $offset
} {
set shown [expr {$shown + 1}]
tkt_render_table_row $xid $xtitle $xas $xstatus $xtypelbl $xprio $xsub $xmod_utc $xcre_utc $xmod_day 1
}
} else {
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) AS xmod_utc,
datetime(t.tkt_ctime) AS xcre_utc,
substr(datetime(t.tkt_mtime),1,10) AS xmod_day
FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fscope='' OR ($fscope='involved' AND EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user())))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.foundin,'') 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
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 END
END ASC,
CASE WHEN $tcol='priority' AND $tdir='desc' THEN
CASE
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 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 OFFSET $offset
} {
set shown [expr {$shown + 1}]
tkt_render_table_row $xid $xtitle "" $xstatus $xtypelbl $xprio $xsub $xmod_utc $xcre_utc $xmod_day 0
}
}
if {$shown == 0} {
set csp 7; if {$hasAssignee} { set csp 8 }
set u_clr_t [tkt_url $st table $sort $grp "" "" "" "" "" "" $tcol $tdir "" "" "" 1 $defaultSort $defaultGrp]
set u_all_t [tkt_url all table $sort $grp $qclean $ftype $fprio $fsev $fsub "" $tcol $tdir "" $fas "" 1 $defaultSort $defaultGrp]
html "<tr><td colspan='$csp' class='tkt-empty'>No tickets match this filter. <a href='$u_clr_t'>Clear filters</a> or <a href='$u_all_t'>search all [htmlize $nall] tickets</a>.</td></tr>\n"
}
html "</tbody></table></div>\n"
} else {
html "<div class='tkt-board-bar'>\n"
html "<details class='tkt-fpop' data-tkt-popover='1'><summary><span>columns</span><strong>[htmlize $grp]</strong>[tkt_chev_svg]</summary><div class='tkt-fpop-menu'>\n"
set gopts {status priority subsystem}
if {$hasAssignee} { set gopts {assignee status priority subsystem} }
foreach gopt $gopts {
set gcur ""; set gchk ""
if {$grp eq $gopt} { set gcur " is-cur"; set gchk "<span class='tkt-fpop-cnt'>✓</span>" }
set u_grp [tkt_url $st board $sort $gopt $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage 1 $defaultSort $defaultGrp]
html "<a class='tkt-fpop-item$gcur' href='$u_grp'><span>$gopt</span>$gchk</a>\n"
}
html "</div></details>"
if {[capexpr {w}]} {
if {$grp eq "assignee"} {
html "<span class='tkt-help'>Drag cards between columns to reassign ownership, or open Move on any card.</span>"
} else {
html "<span class='tkt-help'>Drag cards between columns or open Move on any card.</span>"
}
}
html "</div>\n"
html "<div class='tkt-moved-banner' id='tkt-moved-banner' hidden role='status'></div>\n"
set colList {}
if {$grp eq "assignee" && $hasAssignee} {
if {$fas ne ""} {
if {$fas eq "__unassigned__"} {
lappend colList nobody
} else {
lappend colList $fas
}
} else {
if {$hasLogin} { lappend colList $curUser }
lappend colList nobody
query -nocomplain {
SELECT assignee AS av, count(*) AS ac FROM ticket
WHERE length(assignee)>0 AND assignee<>'nobody'
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
AND ($fage='' OR julianday('now') - tkt_mtime <= CAST($fage AS REAL))
GROUP BY assignee ORDER BY ac DESC, assignee ASC LIMIT 8
} {
if {$av ne $curUser && [llength $colList] < 8} {
lappend colList $av
}
}
}
} elseif {$grp eq "status"} {
set rawCols {Open Review Fixed Closed}
if {[info exists status_choices]} {
if {[llength $status_choices] > 0 && [llength $status_choices] <= 5} {
set rawCols $status_choices
}
}
foreach sc $rawCols {
set isCls 0
if {$sc eq "Fixed" || $sc eq "Tested" || $sc eq "Closed" || $sc eq "Deferred" || $sc eq "Deleted" || $sc eq "Rejected"} { set isCls 1 }
if {$st eq "open" && !$isCls} {
lappend colList $sc
} elseif {$st eq "closed" && $isCls && ($sc ne "Deleted" || $fstat eq "Deleted")} {
lappend colList $sc
} elseif {$st eq "all" && ($sc ne "Deleted" || $fstat eq "Deleted")} {
lappend colList $sc
}
}
if {[llength $colList] == 0} { set colList $rawCols }
} elseif {$grp eq "priority"} {
query {
SELECT DISTINCT priority AS pv FROM ticket WHERE length(priority)>0
ORDER BY CASE
WHEN priority IN ('Immediate','9 Immediate') OR priority GLOB '9*' THEN 1
WHEN priority GLOB '8*' THEN 2
WHEN priority IN ('High','7 High') OR priority GLOB '7*' THEN 3
WHEN priority GLOB '6*' THEN 4
WHEN priority IN ('Medium','5 Medium') OR priority GLOB '5*' THEN 5
WHEN priority GLOB '4*' THEN 6
WHEN priority IN ('Low','3 Low') OR priority GLOB '3*' THEN 7
WHEN priority GLOB '2*' THEN 8
WHEN priority IN ('Zero','1 Zero') OR priority GLOB '1*' THEN 9
ELSE 10 END, priority
LIMIT 9
} {
lappend colList $pv
}
if {[llength $colList] == 0} { set colList {Immediate High Medium Low Zero} }
} elseif {$grp eq "subsystem"} {
if {$fsub ne ""} {
lappend colList $fsub
} else {
query {
SELECT subsystem AS sv, count(*) AS sc FROM ticket
WHERE length(subsystem)>0 AND subsystem<>'None'
AND (($st='all')
OR ($st='open' AND coalesce(status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
AND ($fage='' OR julianday('now') - tkt_mtime <= CAST($fage AS REAL))
GROUP BY subsystem ORDER BY sc DESC, subsystem ASC 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 colLbl $colVal
if {$grp eq "assignee"} {
if {$colVal eq "nobody"} {
set colLbl "Unassigned"
} elseif {$hasLogin && $colVal eq $curUser} {
set colLbl "@$colVal (me)"
} else {
set colLbl "@$colVal"
}
}
set colCnt 0
if {$hasAssignee} {
query -nocomplain {
SELECT count(*) AS nc
FROM ticket t
WHERE (($st='all')
OR ($st='open' AND coalesce(t.status,'Open') NOT IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fas='' OR ($fas='__unassigned__' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$fas)
AND ($fscope=''
OR ($fscope='mine' AND t.assignee=user())
OR ($fscope='unassigned' AND coalesce(t.assignee,'') IN ('','nobody'))
OR ($fscope='involved' AND (t.assignee=user() OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.assignee,'') LIKE $qpat
OR coalesce(t.foundin,'') 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)
OR ($grp='assignee' AND (($colVal='nobody' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$colVal)))
} {
set colCnt $nc
}
} else {
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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fscope='' OR ($fscope='involved' AND EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user())))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.foundin,'') 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]' data-col-total='[htmlize $colCnt]'>\n"
html "<div class='tkt-col-hdr'><span class='tkt-col-hdr-l'>[htmlize $colLbl] <span class='tkt-col-cnt'>[htmlize $colCnt]</span></span></div>\n"
set colRendered 0
proc tkt_render_board_card {xid xtitle xstatus xtypelbl xprio xsub xmod_utc xcre_utc xmod_day xmsgs xcis xas grp colVal colList canWrite hasAssignee} {
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 "" && $xsub ne "None") || ($grp ne "status" && ($xstatus eq "Pending" || $xstatus eq "Review"))} {
html "<div class='tkt-bcard-tags'>"
if {$grp ne "priority" && $xprio ne ""} {
set pcls "tkt-tag"
if {$xprio eq "Immediate" || $xprio eq "High" || [string match 9* $xprio] || [string match 8* $xprio] || [string match 7* $xprio]} { set pcls "tkt-tag tkt-tag-crit" }
html "<span class='$pcls'>[htmlize $xprio]</span>"
}
if {$grp ne "subsystem" && $xsub ne "" && $xsub ne "None"} {
html "<span class='tkt-tag'>[htmlize $xsub]</span>"
}
if {$grp ne "status" && ($xstatus eq "Pending" || $xstatus eq "Review")} {
html "<span class='tkt-tag tkt-tag-warn'>[htmlize $xstatus]</span>"
}
html "</div>"
}
html "<div class='tkt-bcard-foot'><span class='tkt-bcard-meta'><code class='tkt-bcard-id'>[[htmlize $xid]]</code>"
if {$xtypelbl ne ""} { html " · [htmlize $xtypelbl]" }
html " · <button type='button' class='tkt-time-btn' data-tkt-time='1' data-tkt-mod='[htmlize $xmod_utc]' data-tkt-cre='[htmlize $xcre_utc]' data-tkt-kind='board' title='Updated [htmlize $xmod_utc] UTC'>[htmlize $xmod_day]</button>"
if {$xmsgs > 0} {
set mtip "$xmsgs comment"
if {$xmsgs != 1} { set mtip "$xmsgs comments" }
html " · <span class='tkt-bcard-cnt' title='[htmlize $mtip]'>[tkt_note_svg][htmlize $xmsgs]</span>"
}
if {$xcis > 0} {
set ctip "$xcis linked check-in"
if {$xcis != 1} { set ctip "$xcis linked check-ins" }
html " · <span class='tkt-bcard-cnt' title='[htmlize $ctip]'>[tkt_ci_svg][htmlize $xcis]</span>"
}
html "</span><span class='tkt-bcard-act'>"
if {$hasAssignee && $grp ne "assignee"} {
if {$xas eq "" || $xas eq "nobody"} {
html "<span class='tkt-owner is-unassigned'>unassigned</span>"
} else {
html "<span class='tkt-owner'>@[htmlize $xas]</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)"} {
set dstLbl $dst
if {$grp eq "assignee"} {
if {$dst eq "nobody"} { set dstLbl "Unassigned" } else { set dstLbl "@$dst" }
}
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 $dstLbl]</button></form>"
}
}
html "</div></details>"
}
html "</span></div></article>\n"
}
if {$hasAssignee} {
query -nocomplain {
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,
coalesce(t.assignee,'') AS xas,
datetime(t.tkt_mtime) AS xmod_utc,
datetime(t.tkt_ctime) AS xcre_utc,
substr(datetime(t.tkt_mtime),1,10) AS xmod_day,
(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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fas='' OR ($fas='__unassigned__' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$fas)
AND ($fscope=''
OR ($fscope='mine' AND t.assignee=user())
OR ($fscope='unassigned' AND coalesce(t.assignee,'') IN ('','nobody'))
OR ($fscope='involved' AND (t.assignee=user() OR EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user()))))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.assignee,'') LIKE $qpat
OR coalesce(t.foundin,'') 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)
OR ($grp='assignee' AND (($colVal='nobody' AND coalesce(t.assignee,'') IN ('','nobody')) OR t.assignee=$colVal)))
ORDER BY
CASE WHEN $sort='priority' THEN
CASE
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 END
ELSE 0 END ASC,
t.tkt_mtime DESC
LIMIT 60
} {
set colRendered [expr {$colRendered + 1}]
set shown [expr {$shown + 1}]
tkt_render_board_card $xid $xtitle $xstatus $xtypelbl $xprio $xsub $xmod_utc $xcre_utc $xmod_day $xmsgs $xcis $xas $grp $colVal $colList $canWrite 1
}
} else {
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) AS xmod_utc,
datetime(t.tkt_ctime) AS xcre_utc,
substr(datetime(t.tkt_mtime),1,10) AS xmod_day,
(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','Deleted','Rejected'))
OR ($st='closed' AND coalesce(t.status,'Open') IN ('Fixed','Tested','Closed','Deferred','Deleted','Rejected')))
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 ($fscope='' OR ($fscope='involved' AND EXISTS (SELECT 1 FROM ticketchng c WHERE c.tkt_id=t.tkt_id AND c.login=user())))
AND ($fage='' OR julianday('now') - t.tkt_mtime <= CAST($fage AS REAL))
AND ($qclean=''
OR t.title LIKE $qpat
OR coalesce(t.subsystem,'') LIKE $qpat
OR coalesce(t.type,'') LIKE $qpat
OR coalesce(t.foundin,'') 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
WHEN t.priority IN ('Immediate','9 Immediate') OR t.priority GLOB '9*' THEN 1
WHEN t.priority GLOB '8*' THEN 2
WHEN t.priority IN ('High','7 High') OR t.priority GLOB '7*' THEN 3
WHEN t.priority GLOB '6*' THEN 4
WHEN t.priority IN ('Medium','5 Medium') OR t.priority GLOB '5*' THEN 5
WHEN t.priority GLOB '4*' THEN 6
WHEN t.priority IN ('Low','3 Low') OR t.priority GLOB '3*' THEN 7
WHEN t.priority GLOB '2*' THEN 8
WHEN t.priority IN ('Zero','1 Zero') OR t.priority GLOB '1*' THEN 9
ELSE 10 END
ELSE 0 END ASC,
t.tkt_mtime DESC
LIMIT 60
} {
set colRendered [expr {$colRendered + 1}]
set shown [expr {$shown + 1}]
tkt_render_board_card $xid $xtitle $xstatus $xtypelbl $xprio $xsub $xmod_utc $xcre_utc $xmod_day $xmsgs $xcis "" $grp $colVal $colList $canWrite 0
}
}
if {$colRendered == 0} {
html "<div class='tkt-empty tkt-col-empty'>No tickets</div>\n"
} elseif {$colCnt > $colRendered} {
html "<div class='tkt-col-foot'>Showing [htmlize $colRendered] of [htmlize $colCnt] — narrow with Active 30d or subsystem</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>"
if {$view ne "board" && $nmatch > 0} {
set rStart [expr {$offset + 1}]
set rEnd [expr {$offset + $shown}]
if {$nmatch > $shown || $pg > 1} {
html "Showing [htmlize $rStart]–[htmlize $rEnd] of [htmlize $nmatch] matching tickets"
} else {
html "Showing [htmlize $shown] ticket"
if {$shown != 1} { html "s" }
}
} else {
html "Showing [htmlize $shown] ticket"
if {$shown != 1} { html "s" }
}
html "</span><span class='tkt-pager'>"
if {$view ne "board" && $pg > 1} {
set prevPg [expr {$pg - 1}]
set u_prev [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage $prevPg $defaultSort $defaultGrp]
html "<a class='tkt-btn' href='$u_prev'>← Previous 200</a>"
}
if {$view ne "board" && ($offset + $shown) < $nmatch} {
set nextPg [expr {$pg + 1}]
set u_next [tkt_url $st $view $sort $grp $qclean $ftype $fprio $fsev $fsub $fstat $tcol $tdir $fscope $fas $fage $nextPg $defaultSort $defaultGrp]
html "<a class='tkt-btn' href='$u_next'>Next 200 →</a>"
}
if {$qclean ne "" || $st ne "open" || $ftype ne "" || $fprio ne "" || $fsev ne "" || $fsub ne "" || $fstat ne "" || $fscope ne "" || $fas ne "" || $fage ne ""} {
html "<a href='reportlist'>Reset filters</a>"
}
html "</span></div>\n"
}
</th1>
</div>