//Main Global variable definition. These constants and literals are
//used throughout the application
var scrolltable = "file";
var type = "File";
var blankalpha = "";
var zeronum = 0;
var prevlabel = "Page Up";
var nextlabel = "Page Dn";
var backvalue = "Back";
var result = 0;
var toplabel = "Top of List";
// end globals
/* The following logic is needed because when coming from sa08, the group/phase is passed as a parm on an HREF command. When this page is accessed via the "back button" from sa08s, a hidden object is used to pass the group/phase. It appears that the encoding of spaces is treated differently for these two different data types. Therefore an "unescape" command is needed when coming from sa08s, but not when coming from sa08*/
if ((request.back == backvalue)||(request.prevbutt == prevlabel)||(request.nextbutt==nextlabel)||(request.prevbutt==toplabel))
{
request.foldername = unescape(request.foldername);
request.group = unescape(request.group);
}
groupHeader(request.group, type);
write("");
write("Choose a File from the " + request.foldername +" Folder,
Which is Part of the " + request.group +" Phase
");
write("");
//The following code determins if the user has pressed page up or page down
// and sets filepagenum, which scrolls accordingly
if (request.prevbutt == prevlabel)
{client.filepagenum = request.prevpagenum}
if (request.prevbutt == toplabel)
{client.filepagenum = 1}
if(request.nextbutt==nextlabel)
{client.filepagenum = request.nextpagenum}
function CursorMaster_SA08S()
//this is the cursor SELECT statement executed by a user with System Administration
// authority.
{
// This first SELECT gets the scroll keys from the scroll key table
temppage3 = new TopPage(client.userid, scrolltable, client.filepagenum,
blankalpha, blankalpha, zeronum, zeronum);
temppage3.sel_scroll();
//Once the starting point on the page has been determined,
// the cursor for the application specific data can be selected
FileList=database.cursor('SELECT filename, format, ownerid, description FROM file WHERE folderid = "'+ request.folderid + '" AND filename >= "' + temppage3.alphakey1 + '" ORDER BY filename')
}
function CursorUser_SA08S()
//this is the cursor SELECT statement executed by a user who does NOT have System Administration
// authority.
{
// This first SELECT gets the scroll keys from the scroll key table
temppage4 = new TopPage(client.userid, scrolltable, client.filepagenum,
blankalpha, blankalpha, zeronum, zeronum);
temppage4.sel_scroll();
//Once the starting point on the page has been determined,
// the cursor for the application specific data can be selected
FileList=database.cursor('SELECT filename, format, ownerid, description FROM file WHERE folderid = "'+ request.folderid + '" AND filename >= "' + temppage4.alphakey1 + '" AND ownerid = "' + client.userid + '" ORDER BY filename')
}
function BuildTableHeader_SA08S()
// Building the column headers for the table
{
write("");
write("");
write("Existing Files, Page " + client.filepagenum + "");
write("Mod | ");
write("Del | ");
write("File | ");
write("Format | ");
write("Owner ID | ");
write("Description |
");
}
function BuildTableData_SA08S()
// Building the selected data and inserting it into the table. Buttons
// Are added for modify/delete functionality
{
var keepfetching = "true";
var indx=1;
var printhead = "false";
while (keepfetching == "true")
{
if(FileList.next())
{if(printhead=="false")
{BuildTableHeader_SA08S();
printhead = "true";}
if(indx<11)
{var filename = escape(FileList.filename) // format the dates first
write(" | ");
write(" | ");
write("" + FileList.filename + " | ");
write("" + FileList.format + " | ");
write("" + FileList.ownerid+ " | ");
write("" + FileList.description + " |
");
indx++;
}
else {keepfetching = "false";}
}
else{keepfetching = "false";
indx = 10;} // needed to prevent page down from printing if 10th row is last one.
}; // end WHILE loop
// If no rows are found, a message is displayed to the user.
if((printhead=="false") && (client.filepagenum==1))
{ Print_No_Found();}
// Since the table on the page contains 10 rows, the 11th row is saved.
// The data from this row becomes the next entry in Scrollkey, and will tell
// the application where to start when the user presses "Page Dn"
if(indx == 11)
{
var nextpage = 0;
nextpage = parseInt(client.filepagenum) + 1;
var file = ""+FileList.filename+"";
FileList.close()
temppage1 = new TopPage(client.userid, scrolltable, nextpage,
file, blankalpha, zeronum, zeronum);
newpageresult = temppage1.ins_scroll();
// If this row already exists, alpha or numeric key data is updated in case
// a row has been updated since the user last accessed the page.
if(newpageresult !=0)
{temppage1.upd_scroll();};
};
write("
");
return indx;
}
function DeterminePaging_SA08S()
{
write("
"); //begin building table to contain buttons at bottom of page
write("");
// The Top button is displayed if the user in on page >2
if (client.filepagenum >2)
{CreateTopButton_SA08S()};
// The previous button is not displayed if the user in on page 1
if (client.filepagenum != 1)
{CreatePrevButton_SA08S()};
// The next button is not displayed if there is no more data to display
if(indx == 11)
{CreateNextButton_SA08S()};
}
function CreateTopButton_SA08S()
{
// the page number is set back to 1 on reentry
//these two statement pack the spaces with plus signs.
var escapegroup = escape(request.group);
var escapefolder = escape(request.foldername);
write(" | ");
}
function CreatePrevButton_SA08S()
{
// the page number is set back one value when the user presses "Page Up"
var prevpage = parseInt(client.filepagenum) - 1;
//these two statement pack the spaces with plus signs.
var escapegroup = escape(request.group);
var escapefolder = escape(request.foldername);
write(" | ");
}
function CreateNextButton_SA08S()
{
// the page number is set forward one value when the user presses "Page Dn"
var newpage = parseInt(client.filepagenum) + 1;
//these two statement pack the spaces with plus signs.
var escapegroup = escape(request.group);
var escapefolder = escape(request.foldername);
write(" | ");
}
function FolderListButton_SA08S ()
{
var escapegroup = escape(request.group);
write(" | ");
}
// This logic is executed when the user first hits the page.
if((client.filepagenum == "null")||(client.filepagenum == null))
{
// Creating the initial Scrollkey value for the first page
client.filepagenum = 1
temppage2 = new TopPage(client.userid, scrolltable, 1,
blankalpha, blankalpha, zeronum, zeronum);
pageoneresult = temppage2.ins_scroll();
if(pageoneresult !=0)
{temppage2.upd_scroll();}
}
//Different logic exists for users designated as an "Administrator" versus normal users.
if(client.accesslevel == "A")
{CursorMaster_SA08S();}
else
{CursorUser_SA08S();}
indx = BuildTableData_SA08S();
DeterminePaging_SA08S();
FolderListButton_SA08S();
write("
");