Page MenuHomec4science

DAMStat.php.wml
No OneTemporary

File Metadata

Created
Fri, Jan 24, 14:24

DAMStat.php.wml

## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#include "configbis.wml"
<?
require("<LIBDIR>/php/cdsware/websubmit/commonPhpFunctions.php");
?>
#include "cdspage.wml" \
title="Check Documents Status" \
navbar_name="main" \
navbar_select="submit_referee" \
cdspageboxlefttopadd="<protect><?displayLoginMenu('submit');?></protect>"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
function selectDoctype()
{
global $formnb;
print " <br>
<small>
<STRONG class=headline>Notice:</STRONG><BR>
Select one of the following types of documents to check the documents status:</small>
<CENTER><BR>";
$res = mysql_query("select DISTINCT doctype from sbmAPPROVAL") or outError("DAMStat: ".mysql_error());
while ($row = mysql_fetch_row($res))
{
$res2 = mysql_query("select ldocname from sbmDOCTYPE where sdocname='".$row[0]."'") or outError("DAMStat: ".mysql_error());
$row2 = mysql_fetch_row($res2);
print "<small><A HREF='DAMStat.php?doctype=$row[0]'>$row2[0]</A></small><BR>";
}
print "</CENTER>";
}
function selectCateg()
{
global $doctype,$URLPATH,$categ,$formnb,$IMAGES;
$res = mysql_query("select ldocname from sbmDOCTYPE where sdocname='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$title = $row[0];
$sth = mysql_query("select * from sbmCATEGORIES where doctype='$doctype' order by lname") or outError("DAMStat: ".mysql_error());
if (mysql_num_rows($sth) == 0)
{
$categ = "unknown";
selectDocument();
return;
}
print "
<BR>
<SMALL>
<STRONG class=headline>Notice:</STRONG><BR>
Please choose a category
</SMALL>
<BR><BR>";
print "
<FORM action=\"DAMStat.php\" method=get>\n";
?>
<?
print " <INPUT type=hidden name=doctype value='$doctype'>\n";
print " <INPUT type=hidden name=categ value=''>\n";
print " </FORM>\n";
?>
<TABLE align=center>
<TR>
<TD align=center>
<?
while ($arr =mysql_fetch_row($sth)) {
$waiting = 0;
$rejected = 0;
$approved = 0;
$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());
$arr2 = mysql_fetch_row($sth2);
mysql_free_result($sth2);
$rejected = $arr2[0];
$num = $waiting + $approved + $rejected;
if ($waiting != 0) { $class = "class=results"; } else { $class = ""; }
print "
<A href=\"\" onClick=\"document.forms[$formnb].categ.value='$arr[1]';document.forms[$formnb].submit();return false;\"><SMALL $class>$arr[2]</SMALL></A><SMALL> ($num document<SMALL>(</SMALL>s<SMALL>)</SMALL>\n";
if ($waiting != 0)
{
print "| $waiting <IMG ALT=\"pending\" SRC=\"$IMAGES/waiting_or.gif\" border=0>\n";
}
if ($approved != 0)
{
print "| $approved <IMG ALT=\"approved\" SRC=\"$IMAGES/smchk_gr.gif\" border=0>\n";
}
if ($rejected != 0)
{
print "| $rejected <IMG ALT=\"rejected\" SRC=\"$IMAGES/cross_red.gif\" border=0>\n";
}
print ")</SMALL><BR>\n";
}
mysql_free_result($sth);
?>
</TD>
<TD>&nbsp;</TD>
<TD>
<TABLE cellpadding=1 cellspacing=0 border=0><TR class="headerselected"><TD>
<TABLE width="100%" bgcolor="white" cellspacing=0 cellpadding=5 border=0><TR><TD>
<SMALL>
<B class=headline>Key:</B><BR>
<?
print "
<IMG ALT=\"pending\" SRC=\"$IMAGES/waiting_or.gif\" border=0> waiting for approval<BR>
<IMG ALT=\"approved\" SRC=\"$IMAGES/smchk_gr.gif\" border=0> already approved<BR>
<IMG ALT=\"rejected\" SRC=\"$IMAGES/cross_red.gif\" border=0> rejected<BR><BR>\n";
?>
<SMALL class=results>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SMALL> some documents are pending<BR>
</SMALL>
</TD></TR></TABLE>
</TD></TR></TABLE>
</TD>
</TR>
</TABLE>
<?
}
function selectDocument()
{
global $doctype,$categ,$URLPATH,$formnb,$IMAGES;
$res = mysql_query("select ldocname from sbmDOCTYPE where sdocname='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$title = $row[0];
if ($categ == "") { $categ == "unknown"; }
print "
<SMALL>
<STRONG class=headline>Notice:</STRONG><BR>
Click on a report number to have more information
</SMALL>
<BR>";
print "
<FORM action=\"$URLPATH/publiline/inotes/DAMStat.php\" method=get>\n";
print " <INPUT type=hidden name=doctype value='$doctype'>\n";
print " <INPUT type=hidden name=categ value='$categ'>\n";
print " <INPUT type=hidden name=RN value=''>\n";
print " </FORM>\n";
print "<TABLE border=1>";
print "<TR><TH><SMALL><STRONG class=headline>Report Number</STRONG></SMALL></TH><TH><SMALL><STRONG class=headline>Waiting for Approval<BR>(Internal Notes)</STRONG></SMALL></TH><TH><SMALL><STRONG class=headline>Approved</STRONG></SMALL></TH><TH><SMALL><STRONG class=headline>Rejected</STRONG></SMALL></TH></TR>";
if ($categ == "") { $categ = "unknown"; }
$query = "select rn,status from sbmAPPROVAL where doctype='$doctype' and categ='$categ' order by status DESC,rn DESC";
$sth = mysql_query($query) or outError("DAMStat: ".mysql_error());
while ($arr = mysql_fetch_row($sth)) {
$RN = $arr[0];
$status = $arr[1];
if ( $status == "waiting" )
{
print "<TR><TD align=center><A HREF=\"\" onClick=\"document.forms[$formnb].RN.value='$arr[0]';document.forms[$formnb].submit();return false;\">$RN</A></TD><TD align=center><IMG ALT=\"check\" SRC=\"$IMAGES/waiting_or.gif\"></TD><TD align=center>&nbsp;</TD><TD align=center>&nbsp;</TD></TR>";
}
elseif ( $status == "rejected" )
{
print "<TR><TD align=center><A HREF=\"\" onClick=\"document.forms[$formnb].RN.value='$arr[0]';document.forms[$formnb].submit();return false;\">$RN</A></TD><TD align=center>&nbsp;</TD><TD align=center>&nbsp;</TD><TD align=center><IMG ALT=\"check\" SRC=\"$IMAGES/cross_red.gif\"></TD></TR>";
}
elseif ( $status == "approved" )
{
print "<TR><TD align=center><A HREF=\"\" onClick=\"document.forms[$formnb].RN.value='$arr[0]';document.forms[$formnb].submit();return false;\">$RN</A></TD><TD align=center>&nbsp;</TD><TD align=center><IMG ALT=\"check\" SRC=\"$IMAGES/smchk_gr.gif\"></TD><TD align=center>&nbsp;</TD></TR>";
}
}
print "</TABLE>";
}
function displayDocument()
{
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());
$arr = mysql_fetch_row($sth);
$status = $arr[1];
$dFirstReq = $arr[2];
$dLastReq = $arr[3];
$dAction = $arr[4];
$access = $arr[5];
if ($status == "waiting")
{
$image = "<IMG SRC=\"$IMAGES/waiting_or.gif\" ALT=\"\" align=right>";
}
elseif ($status == "approved")
{
$image = "<IMG SRC=\"$IMAGES/smchk_gr.gif\" ALT=\"\" align=right>";
}
elseif ($status == "rejected")
{
$image = "<IMG SRC=\"$IMAGES/iconcross.gif\" ALT=\"\" align=right>";
}
else
{
$image = "";
}
print "<TABLE border=1 align=center><TR><TD><SMALL><STRONG class=headline>$image$RN</STRONG></SMALL></TD></TR>";
print "<TR><TD class=header><BR>";
if ($arr[0] == "")
{
print "This document has never been requested for approval!<BR>&nbsp;";
#exit;
}
getInfo();
if ( isset($send) && $send == "Send Again" )
{
if ( $authors == "unknown" || $title == "unknown" )
{
SendWarning();
}
else
{
SendEnglish();
$now = strftime("%Y-%m-%d %H:%M:%S");
$dLastReq = "$now";
if (!TEST)
{
$query = "update sbmAPPROVAL set dLastReq='$now' where rn='$RN'";
$sth = mysql_query($query) or outError("DAMStat: ".mysql_error());
}
print "<I><strong class=headline>Your request has been sent to the referee!</strong></I><BR><BR>";
}
}
print "<FORM action=\"DAMStat.php\">\n";
print "<INPUT type=hidden name=RN value=\"$RN\">\n";
print "<INPUT type=hidden name=categ value=\"$categ\">\n";
print "<INPUT type=hidden name=doctype value=\"$doctype\">\n";
print "<SMALL>\n";
if ($title != "unknown")
{
print "<strong class=headline>Title:</strong> $title<BR><BR>\n";
if ($authors != "")
{
print "<strong class=headline>Author:</strong> $authors<BR><BR>\n";
}
if ($sysno != "")
{
print "<strong class=headline>More information:</strong>";
if (defined("SHORTURLACCESSDOC"))
print " <A HREF=\"".SHORTURLACCESSDOC."?sysno=$sysno\">click here</A><BR><BR>\n";
else
print " <A HREF=\"$ACCESSURL?id=$sysno\">click here</A><BR><BR>\n";
}
}
if ( $status == "waiting" )
{
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:";
print "<BR><INPUT type=submit name=approval value=\"Approve/Reject\" onClick=\"window.location='".$URLPATH."/approve.php?$access';return false;\">";
}
}
if ( $status == "approved" )
{
print "This Document has been <strong class=headline>approved</strong>.<BR>Its approved reference is: <strong class=headline>$newrn</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 "It has been approved on: <strong class=headline>$dAction</STRONG><BR>";
}
if ( $status == "rejected" )
{
print "This Document has been <strong class=headline>rejected</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 "It has been rejected on: <strong class=headline>$dAction</STRONG><BR>";
}
print "</SMALL></FORM>";
print "<BR></TD></TR></TABLE>";
}
// Retrieve info about document
function getInfo()
{
global $RN,$authors,$title,$doctype,$linker;
if (!getInPending())
{
getInAlice();
}
}
#seek info in pending directory
function getInPending()
{
global $RN,$authors,$title,$doctype,$STORAGE;
$PENDIR="$STORAGE/pending";
if (is_file("$PENDIR/$doctype/$RN/AU")) { $authors=`cat $PENDIR/$doctype/$RN/AU`;} else { $authors = ""; }
if (is_file("$PENDIR/$doctype/$RN/TI")) { $title=`cat $PENDIR/$doctype/$RN/TI`; } else { $title = ""; }
if ( $title == "" )
{
if (is_file("$PENDIR/$doctype/$RN/TIF")) { $title=`cat $PENDIR/$doctype/$RN/TIF`;} else { $title = ""; }
}
if ( $title == "" )
{
return false;
}
return true;
}
#seek info in Alice database
function getInAlice()
{
global $RN,$authors,$title,$sysno,$newrn,$status,$doctype,$api_path,$modifybase,$logicalbase;
$tag = "037__a";
$tablename = "bib".substr($tag,0,2)."x";
$res = mysql_query("select id from $tablename where value='$RN' and tag='$tag'") or outError("DAMStat: ".mysql_error());
if ($row = mysql_fetch_row($res))
{
$res2 = mysql_query("select id_bibrec from bibrec_$tablename where id_bibxxx='$row[0]'") or outError("DAMStat: ".mysql_error());
$row2 = mysql_fetch_row($res2);
$sysno = "$row2[0]";
$title = Get_Field('245__a',$sysno);
$authors = Get_Field('100__a',$sysno);
$authors .= Get_Field('700__a',$sysno);
$newrn = Get_Field('037__a',$sysno);
return true;
}
else
{
print "Sorry... I Cannot find this document data in our database... Please contact the support team....";
$title = "unknown";
$authors = "unknown";
return false;
}
}
function SendEnglish()
{
global $RN,$access,$title,$authors,$doctype,$URLPATH,$LINKMANAGER,$categ;
//retrieve useful information from MESS configuration
$res = mysql_query("select value from sbmPARAMETERS where name='categformatDAM' and doctype='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$categformat = $row[0];
$categformat = ereg_replace("<CATEG>","([^-]*)",$categformat);
ereg($categformat,$RN,$categ);
if ( $categ[1] == "" ) { $categ[1] = "unknown"; }
$categ = $categ[1];
$res = mysql_query("select value from sbmPARAMETERS where name='addressesDAM' and doctype='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$otheraddresses = $row[0];
$otheraddresses = str_replace("<CATEG>",$categ,$otheraddresses);
// Build referee's email address
$refereeaddress = "";
# Try to retrieve the referee's email from the referee's database
$res = mysql_query("select id_user from user_rule where id_rule=".getRuleID("referee")." and param1='$doctype' and (param2='$categ' or param2='*')");
while ($row = mysql_fetch_row($res))
$refereeaddress .= getEmail($row[0]).",";
$refereeaddress = ereg_replace(",$","",$refereeaddress);
$MAddress = $refereeaddress . (($refereeaddress!="" && $otheraddresses!="") ? "," : "") . $otheraddresses;
$res = mysql_query("select value from sbmPARAMETERS where name='linkerpgm' and doctype='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$linker = $row[0];
$res = mysql_query("select value from sbmPARAMETERS where name='arnpgm' and doctype='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$ARNfile = $row[0];
$res = mysql_query("select value from sbmPARAMETERS where name='edsrn' and doctype='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$RNfield = $row[0];
$res = mysql_query("select value from sbmPARAMETERS where name='directory' and doctype='$doctype'") or outError("DAMStat: ".mysql_error());
$row = mysql_fetch_row($res);
$directory = $row[0];
if ($MAddress==""||$linker==""||$ARNfile=="")
{
SendWarning();
return false;
}
if ($authors == "") $authors = "-";
$message = "
The document $RN has been published as a Communication.
Your approval is requested for it to become an official Note.
Title: $title
Author(s): $authors
To access the document(s), select the file(s) from the location:
<$LINKMANAGER?base=$directory&id=$RN>
To approve/reject the document, you should go to this URL:
<$URLPATH/approve.php?$access>
---------------------------------------------
Best regards.
The submission team.";
if (TEST)
mail(ADMIN_EMAIL,"Request for Approval of $RN sent to $MAddress","$message","from: ".SUPPORTEMAIL);
else
mail ("$MAddress,".ADMIN_EMAIL,"Request for Approval of $RN","$message","from: ".SUPPORTEMAIL."\nbcc: ".ADMIN_EMAIL);
}
function SendWarning()
{
global $RN;
$message = "
DAMRecall failed for $RN";
mail (ADMIN_EMAIL,"DAMRecall failed","$message","from: ".SUPPORTEMAIL );
}
/*********************Start main script*******************/
connectDB(DOCS_DATABASE);
$formnb = 1;
if (AUTHENTICATION)
include ("${HTDOCSDIR}submit/MESS/functions/Retrieve_Data.php");
if ($doctype == "")
selectDoctype();
elseif ($categ == "")
selectCateg();
elseif ($RN == "")
selectDocument();
else
displayDocument();
/*********************End main script*******************/
?>
</protect>

Event Timeline