I was creating a bunch of pre-canned responses earlier and I couldn't remember which ones I had already made.
I thought, wouldn't it be helpful if I could see the responses I had already created on the same page where I create a new one?
replace all of the code in include/staff/reply.inc.php with this code...
<?php
if(!defined('OSTSCPINC') or !$thisuser->canManageKb()) die('Access Denied');
$info=($errors && $_POST)?Format:($_POST):($answer);
if($answer && $_REQUEST!='add'){
$title='Edit Premade Reply';
$action='update';
}else {
$title='Add New Premade Reply';
$action='add';
$info=1;
}
?>
<div>
<?if($errors) {?>
<p align="center" id="errormessage"><?=$errors?></p>
<?}elseif($msg) {?>
<p align="center" id="infomessage"><?=$msg?></p>
<?}elseif($warn) {?>
<p id="warnmessage"><?=$warn?></p>
<?}?>
</div>
<div class="msg"><?=$title?></div>
<table width="100%" border="0" cellspacing=1 cellpadding=2>
<form action="kb.php" method="POST" name="group">
<input type="hidden" name="a" value="<?=$action?>">
<input type="hidden" name="id" value="<?=$info?>">
<tr><td width=80px>Title:</td>
<td><input type="text" size=45 name="title" value="<?=$info?>">
<font class="error">* <?=$errors?></font>
</td>
</tr>
<tr>
<td>Status:</td>
<td>
<input type="radio" name="isenabled" value="1" <?=$info?'checked':''?> /> Active
<input type="radio" name="isenabled" value="0" <?=!$info?'checked':''?> />Offline
<font class="error"> <?=$errors?></font>
</td>
</tr>
<tr><td valign="top">Category:</td>
<td>Department under which the 'answer' will be made available. <font class="error"> <?=$errors?></font><br/>
<select name=dept_id>
<option value=0 selected>All Departments</option>
<?
$depts= db_query('SELECT dept_id,dept_name FROM '.DEPT_TABLE.' ORDER BY dept_name');
while (list($id,$name) = db_fetch_row($depts)){
$ck=($info==$id)?'selected':''; ?>
<option value="<?=$id?>" <?=$ck?>><?=$name?></option>
<?
}?>
</select>
</td>
</tr>
<tr><td valign="top">Answer:</td>
<td>Premade Reply - Ticket's base variables are supported. <font class="error">* <?=$errors?></font><br/>
<textarea name="answer" id="answer" cols="90" rows="9" wrap="soft" style="width%"><?=$info?></textarea>
</td>
</tr>
<tr>
<td nowrap> </td>
<td><br>
<input class="button" type="submit" name="submit" value="Submit">
<input class="button" type="reset" name="reset" value="Reset">
<input class="button" type="button" name="cancel" value="Cancel" onClick='window.location.href="kb.php"'>
</td>
</tr>
</form>
</table>
<br />
<br />
<?php
if(!defined('OSTSCPINC') or !is_object($thisuser) or !$thisuser->canManageKb()) die('Access Denied');
//List premade answers.
$select='SELECT premade.*,dept_name ';
$from='FROM '.KB_PREMADE_TABLE.' premade LEFT JOIN '.DEPT_TABLE.' USING(dept_id) ' ;
//make sure the search query is 3 chars min...defaults to no query with warning message
if($_REQUEST=='search') {
if(!$_REQUEST || strlen($_REQUEST)<3) {
$errors='Search term must be more than 3 chars';
}else{
//fulltext search.
$search=true;
$qstr.='&a='.urlencode($_REQUEST);
$qstr.='&query='.urlencode($_REQUEST);
$where=' WHERE MATCH(title,answer) AGAINST ('.db_input($_REQUEST).')';
if($_REQUEST)
$where.=' AND dept_id='.db_input($_REQUEST);
}}
//I admit this crap sucks...but who cares??
$sortOptions=array('createdate'=>'premade.created','updatedate'=>'premade.updated','title'=>'premade.title');
$orderWays=array('DESC'=>'DESC','ASC'=>'ASC');
//Sorting options...
if($_REQUEST) {
$order_column =$sortOptions[$_REQUEST;
}
if($_REQUEST) {
$order=$orderWays[$_REQUEST;
}
$order_column=$order_column?$order_column:'premade.title';
$order=$order?$order:'DESC';
$order_by=$search?'':" ORDER BY $order_column $order ";
$total=db_count('SELECT count(*) '.$from.' '.$where);
$pagelimit=$thisuser->getPageLimit();
$pagelimit=$pagelimit?$pagelimit; //true default...if all fails.
$page=($_GET && is_numeric($_GET))?$_GET;
$pageNav=new Pagenate($total,$page,$pagelimit);
$pageNav->setURL('kb.php',$qstr.'&sort='.urlencode($_REQUEST).'&order='.urlencode($_REQUEST));
//Ok..lets roll...create the actual query
$query="$select $from $where $order_by LIMIT ".$pageNav->getStart().",".$pageNav->getLimit();
//echo $query;
$replies = db_query($query);
$showing=db_num_rows($replies)?$pageNav->showing():'';
$results_type=($search)?'Search Results':'Premade/Canned Replies';
$negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting..
?>
<div>
<?if($errors) {?>
<p align="center" id="errormessage"><?=$errors?></p>
<?}elseif($msg) {?>
<p align="center" id="infomessage"><?=$msg?></p>
<?}elseif($warn) {?>
<p id="warnmessage"><?=$warn?></p>
<?}?>
</div>
<div align="left">
<fieldset style="
padding: 0.2em 0.5em 0.5em 0.5em;
border solid #369;
font-size%;
text-align;
font-weight;
background-color: #c3d9ff;">
<legend >Replies Already Canned </legend>
<table border="0" cellspacing=0 cellpadding=2 class="dtable" align="center" width="100%">
<tr>
<th>
<a href="kb.php?sort=title&order=<?=$negorder?><?=$qstr?>" title="Sort By Title <?=$negorder?>">Reply Title</a></th>
<th width=50>Status</th>
<th width=200>Category/Dept</th>
<th width=150 nowrap>
<a href="kb.php?sort=updatedate&order=<?=$negorder?><?=$qstr?>" title="Sort By Update Date <?=$negorder?>">Last Updated</a></th>
</tr>
<?
$class = 'row1';
$total=0;
$grps=($errors && is_array($_POST))?$_POST;
if($replies && db_num_rows($replies)):
while ($row = db_fetch_array($replies)) {
$sel=false;
if($canned && in_array($row,$canned)){
$class="$class highlight";
$sel=true;
}elseif($replyID && $replyID==$row) {
$class="$class highlight";
}
?>
<tr class="<?=$class?>" id="<?=$row?>">
<td><a href="kb.php?id=<?=$row?>"><?=Format:(Format:($row,60))?></a></td>
<td><b><?=$row?'Active':'Disabled'?></b></td>
<td><?=$row?Format:($row):'All Departments'?></td>
<td><?=Format:($row)?></td>
</tr>
<?
$class = ($class =='row2') ?'row1':'row2';
} //end of while.
else: //nothin' found!! ?>
<?
endif; ?>
</table>
</form>
</fieldset>
And you have this result...

Now, in scp/kb.php, find this line...
$inc=$page?$page:'premade.inc.php';
and replace it with this line
$inc=$page?$page:'reply.inc.php';
Now when you add new response, it will just add to list at bottom, instead of returning to list-only (premade.inc.php) page.
woot.
Lets add in a dropdown menu that will allow you to choose a base var (ex: %email) and insert it into the text field at the caret (cursor).
At the very top of /include/staff/reply.inc.php before the very first <?php, add in this code...
function addtext() {
var newtext = group.Base.options.value;
document.group.answer.value += newtext;
}
Next, find this code...
<textarea name="answer" id="answer" cols="90" rows="9" wrap="soft" style="width%"><?=$info?></textarea>
Directly below,add this code...
padding: 0.2em 0.5em 0.5em 0.5em;
border solid #369;
font-size%;
text-align;
font-weight;
background-color: #c3d9ff;
width: 78%;">
Ticket's base variables are supported.
Choose A Base Var
Ticket ID(internal ID)
Ticket number(external ID)
Email address
Full name
Subject
Help topic (web only)
Phone number | ext
Status
Priority
Department
Assigned staff (if any)
Date created
Due date
Date closed
Message (incoming)
Response (outgoing)
Internal note
Staff's name (alert/notices)
Assigned staff
Staff assigning the ticket
ICI Support Base URL
Don't forget the and tags at the end of the file.
Now we have a nice drop down that appends our base vars to the textbox.

It's just the two pages slammed together, trimmed, styled, and Dr. Frankenstein'd a bit, but its a huge help for me and I hope it helps you.
: