/*===================================================================
The grpArray function creates the Sales Process Phases that are
selected by the user in a drop list. The folder being created or
modified is associated with one of the five phases.
===================================================================
*/
function grpArray()
{ this.length = 5
for (var i = 1; i < 6; i++)
{this[i] = "";}
return this
}
/*======================================================================
The get_db_fldr_rec function retrieves a single folder
from the database. This is a method of the folder object. Once
the folder object has been created and an initial value for
folderid placed in it, this method is called to complete the
population of the objects attribute values.
=======================================================================
*/
function get_db_fldr_rec() //Retrieves a single folder from the database using the interest group id
{ fldr_info = database.cursor('SELECT folderid, foldername, folder.interestgroupid, interestgroup.interestgroup, group, folder.description, ownerid FROM folder, interestgroup WHERE folder.interestgroupid = interestgroup.interestgroupid and folderid = '+this.folderid);
if(fldr_info.next())
{this.folderid = fldr_info.folderid;
this.foldername = ""+fldr_info.foldername+"";
this.interestgroupid = fldr_info.interestgroupid;
this.interestgroup = ""+fldr_info.interestgroup+"";
this.description = ""+fldr_info.description+"";
this.group = ""+fldr_info.group+"";
this.ownerid = ""+fldr_info.ownerid+"";
fldr_info.close();
result = true;
}
else
{write('Record Not Found!
Another administrator has deleted this record!');
result = false;
}
return result;
}
/*======================================================================
The get_db_fldr_rec2 function retrieves a single folder
from the database. This is a method of the folder object. If a
new folder record is created by the user, the application has
no way of getting the folder id generated by the database.
This method attempts to retrieve the record, (including the folder id)
from the database by matching other criteria that it has about the
record.
======================================================================
*/
function get_db_fldr_rec2() //Retrieves a single interest group from the database using the interest group name
{ fldr_info = database.cursor('SELECT folderid, foldername, folder.interestgroupid, interestgroup.interestgroup, group, folder.description, ownerid FROM folder, interestgroup WHERE folder.interestgroupid = interestgroup.interestgroupid and foldername = "'+this.foldername
+'" and group ="'+this.group+'" and folder.interestgroupid = '+this.interestgroupid+' and folder.description = "'+this.description+'"');
if(fldr_info.next())
{this.folderid = fldr_info.folderid;
this.foldername = ""+fldr_info.foldername+"";
this.interestgroupid = fldr_info.interestgroupid;
this.interestgroup = ""+fldr_info.interestgroup+"";
this.description = ""+fldr_info.description+"";
this.group = ""+fldr_info.group+"";
this.ownerid = ""+fldr_info.ownerid+"";
fldr_info.close();
result = true;
}
else
{write('Record Not Found!
Another administrator has deleted this record!');
result = false;
}
return result;
}
/*======================================================================
The ins_db_fldr_rec function inserts a single folder
into the database. This is a method of the folder object.
======================================================================
*/
function ins_db_fldr_rec() //Inserts a folder into the database
{ this.description = check_size(this.description, 255);
this.foldername = check_text_entry(this.foldername);
this.description = check_text_entry(this.description);
result = database.execute('INSERT INTO folder (folderid, foldername, interestgroupid, group, description, ownerid) VALUES ('+this.folderid+',"'
+ this.foldername
+'", '+this.interestgroupid
+' ,"'+this.group
+'","'+this.description
+'","'+this.ownerid
+'")' );
if (result != 0)
{write('
A Database error has occurred ' + result + '');
write('
' + database.majorErrorCode() + '');
write('
' + database.majorErrorMessage() + '');
request.mode="add"};
else
{write('The following Folder has been added.
');}
}
/*======================================================================
The del_db_fldr_rec function deletes a single folder
from the database. This is a method of the folder object.
======================================================================
*/
function del_db_fldr_rec() //Deletes an folder from a database
{ get_count = database.cursor('SELECT * FROM file WHERE folderid='+this.folderid);
if (!get_count.next())
{
get_count.close();
result = database.execute('DELETE FROM folder WHERE folderid='+this.folderid);
if (result != 0)
{write('
A Database error has occurred ' + result + '');
write('
' + database.majorErrorCode() + '');
write('
' + database.majorErrorMessage() + '');
request.mode="D"};
else
{write('Folder: '+this.foldername+' deleted.');
}
}
else
{get_count.close();
write('Unable to delete Folder: '+this.foldername+'
');
write('There are files still linked to this folder!');
}
}
/*======================================================================
The upd_db_fldr_rec function updates a single folder
in the database. This is a method of the folder object.
======================================================================
*/
function upd_db_fldr_rec() //Updates a folder in the database
{ this.description = check_size(this.description, 255);
this.foldername = check_text_entry(this.foldername);
this.description = check_text_entry(this.description);
result = database.execute('UPDATE folder SET foldername = "'+ this.foldername
+'", interestgroupid = '+this.interestgroupid
+' , group = "'+this.group
+'", description = "'+ this.description
+'", ownerid = "'+ this.ownerid
+'" WHERE folderid = '+this.folderid);
if (result != 0)
{write('
A Database error has occurred ' + result + '');
write('
' + database.majorErrorCode() + '');
write('
' + database.majorErrorMessage() + '');
request.mode="M"};
else
{write('The following Folder has been updated.
');}
}
//Folder Object
function fldr_rec(folderid, foldername, interestgroupid, interestgroup, group, description, ownerid)
{ this.folderid = folderid;
this.foldername = foldername;
this.interestgroupid = interestgroupid;
this.interestgroup = interestgroup;
this.group = group;
this.description = description;
this.ownerid = ownerid;
this.ins_db_fldr_rec = ins_db_fldr_rec;
this.upd_db_fldr_rec = upd_db_fldr_rec;
this.get_db_fldr_rec = get_db_fldr_rec;
this.get_db_fldr_rec2 = get_db_fldr_rec2;
this.del_db_fldr_rec = del_db_fldr_rec;
}
/*======================================================================
The load_Folder_Tbl function creates the folder object and
loads it with initial values. The appropriate method is then executed
against the current object based on the mode the form is in. The form
basically has two main categories of modes: user and database. User
modes are add, D (delete), M (modify). Database modes are insert,
dump, and update. Once the initial method has been called on the
object, the specifics of the page formatting are determined based on
field, user access, and mode.
======================================================================
*/
function load_Folder_Tbl()
{ if (request.mode == "insert")
{ temp_fldr = new fldr_rec(request.folderid, request.foldername, request.interestgroupid,"", request.group, request.description, request.ownerid);
temp_fldr.ins_db_fldr_rec();
result = temp_fldr.get_db_fldr_rec2();
}
if (request.mode == "add")
{ temp_fldr = new fldr_rec(0,"",0,"",unescape(request.group),"",client.userid);
result = true;
}
if (request.mode == "dump")
{ temp_fldr = new fldr_rec(request.folderid, request.foldername, request.interestgroupid, "",request.group, request.description, request.ownerid);
temp_fldr.del_db_fldr_rec();
}
if ((request.mode == "M") || (request.mode == "D"))
{ temp_fldr = new fldr_rec(request.folderid,"",0,"","","","");
result = temp_fldr.get_db_fldr_rec();
}
if (request.mode == "update")
{ temp_fldr = new fldr_rec(request.folderid, request.foldername, request.interestgroupid,"", request.group, request.description, request.ownerid);
temp_fldr.upd_db_fldr_rec();
result = temp_fldr.get_db_fldr_rec();
}
if ((request.mode != "dump") && (result))
{
write('');
write('');
result = true;
}
else
{ result = false;
}
return result;
}
write('');
group_list = new grpArray;
group_list[1] = "Generating Leads";
group_list[2] = "Preparing the Proposal";
group_list[3] = "Gaining Commitment";
group_list[4] = "Delivering Value";
group_list[5] = "Gathering Feedback";
result = load_Folder_Tbl();
if (result)
{
write('');
if (request.mode == "add")
{