$sth2 = mysql_query("select COUNT(*) from sbmAPPROVAL where doctype='$doctype' and categ='$arr[1]' and status='waiting'") or outError("DAMStat: ".mysql_error());
$arr2 = mysql_fetch_row($sth2);
mysql_free_result($sth2);
$waiting = $arr2[0];
$sth2 = mysql_query("select COUNT(*) from sbmAPPROVAL where doctype='$doctype' and categ='$arr[1]' and status='approved'") or outError("DAMStat: ".mysql_error());
$arr2 = mysql_fetch_row($sth2);
mysql_free_result($sth2);
$approved = $arr2[0];
$sth2 = mysql_query("select COUNT(*) from sbmAPPROVAL where doctype='$doctype' and categ='$arr[1]' and status='rejected'") or outError("DAMStat: ".mysql_error());
global $doctype,$categ,$RN,$URLPATH,$title,$authors,$access,$send,$sysno,$newrn,$modifybase,$logicalbase,$formnb,$status,$ACCESSURL,$uid_email,$IMAGES;
$res = mysql_query("select ldocname from sbmDOCTYPE where sdocname='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$docname = $row[0];
if ($categ == "") { $categ = "unknown"; }
print " <BR><BR>";
$query = "select rn,status,dFirstReq,dLastReq,dAction,access from sbmAPPROVAL where rn='$RN'";
$sth = mysql_query($query) or outError("DAMStat: ".mysql_error());
print "This Document is still <strong class=headline>waiting for approval</strong>.<BR><BR>";
print "It has first been sent to approval on: <strong class=headline>$dFirstReq</strong><BR>";
if ( $dLastReq == "0000-00-00 00:00:00" )
{
print "Last approval e-mail was sent on: <strong class=headline>$dFirstReq</strong><BR>";
}
else
{
print "Last approval e-mail was sent on: <strong class=headline>$dLastReq</strong><BR>";
}
print "<BR>You can send an approval request e-mail again by clicking the following button:";
print "<BR><INPUT type=submit name=send value=\"Send Again\" onClick=\"return confirm('WARNING! An e-mail will be send to your referee if you confirm.')\">";
// We also display a button for the referee
if ($uid_email != "" && $uid_email != "guest" && authenticate($uid_email,"referee",$doctype,$categ))
{
print "<br>As a referee for this document, you may click this button to approve or reject it:";