%@ Language=VBScript %> <% ' create an array of all users Dim rsUsers Set rsUsers = Server.CreateObject("ADODB.Recordset") If oBS.GetUsers(rsUsers) Then End If ' create an array of all teams Dim rsTeams Set rsTeams = Server.CreateObject("ADODB.Recordset") rsTeams.Open "Select * from Teams","DSN=bsDSN" Dim isTasks 'if user has called this page with querystring If Request("ProjectID") <> "" Then Session("ProjectID") = Request("ProjectID") End If 'if updating a schedule task If Request("ProjectTaskID") <> "" Then EditScheduleTask ' insert some time so that when task our called, updates are reflected ' add some time for i = 0 to 1500000 next End If 'if deleting a schedule task If Request("DeleteTask") <> "" Then DeleteScheduleTask(Request("DeleteTask")) End If 'Get Project Date Information and Product Information Dim rsProject,rsProduct Set rsProject = Server.CreateObject("ADODB.Recordset") Set rsProduct = Server.CreateObject("ADODB.Recordset") If oBS.GetProjects(rsProject,Session("ProjectID")) Then End If 'create default tasks if they have not been created 'Dim rsTest 'Set rsTest = Server.CreateObject("ADODB.Recordset") 'rsTest.Open "Select * from ProjectTasks where ProjectID = " & Cstr(Session("ProjectID")),"DSN=bsDSN" 'if there are no tasks create default ones 'If rsTest.EOF Then 'oBS.CreateSchedule rsProject("TypeID"),rsProject("ProjectID") 'Response.Redirect("project_schedule.asp") 'End If 'rsTest.Close 'set product session (if coming to this page directly from INBOX) Session("ProductID") = rsProject("ProductID") 'if updating project dates If Request("isUpdating") = "isUpdating" Then UpdateDates() End If 'if setting default dates If Request("default") <> "" Then ChangeDates() End If 'instantiate objects for form element creation 'objects to create form elements follow... Dim oAddTask, sRedirect Set oAddTask = oCD.GetInputbox oAddTask.id = "AddTask" oAddTask.group = 4 oAddTask.className = "Buttons" oAddTask.style = "HEIGHT: 25px; LEFT: 24px; POSITION: absolute; TOP: 69px; WIDTH: 67px" oAddTask.value = "Add Task" sRedirect = "window.open('project_schedule_addtask.asp?ProjectID=" & Session("ProjectID") & "','','height=220,width=475,resizable')" oAddTask.extra = "onClick=""" & sRedirect & """" DisableIfNotTM(oAddTask) If oBS.GetProducts(rsProduct,CInt(rsProject("ProductID"))) Then End If Dim oProjectStartDate Set oProjectStartDate = oCD.GetInputbox EnableDisable(oProjectStartDate) oProjectStartDate.id = "ProjectStartDate" oProjectStartDate.className = "Buttons" oProjectStartDate.style = "HEIGHT: 17px; LEFT: 277px; POSITION: absolute; TOP: 69px; WIDTH: 66px" oProjectStartDate.value = rsProject("ProjectStartDate") If Session("SecurityProfile") <> "TM" Then oProjectStartDate.disabled = true End If Dim oTargetCompletionDate Set oTargetCompletionDate = oCD.GetInputbox EnableDisable(oTargetCompletionDate) oTargetCompletionDate.id = "TargetCompletionDate" oTargetCompletionDate.className = "Buttons" oTargetCompletionDate.style = "HEIGHT: 19px; LEFT: 277px; POSITION: absolute; TOP: 94px; WIDTH: 66px" oTargetCompletionDate.value = rsProject("TargetCompletionDate") If Session("SecurityProfile") <> "TM" Then oTargetCompletionDate.disabled = true End If 'rest of form elements comprise the schedule for the project. 'the total number of elements depends on the project and project 'type. Therefore, need to call ListTasks(rs,iProjectID) function. Dim rsTasks Set rsTasks = Server.CreateObject("ADODB.Recordset") Dim iCount,iTask If oBS.ListTasks(rsTasks,Session("ProjectID")) Then 'get number of tasks iCount = rsTasks.RecordCount If iCount = 0 Then isTasks = False Else isTasks = True End If 'Dim an array for task form elements Dim oSchedule() Redim oSchedule(iCount-1,6) Dim fTotalHours fTotalHours = 0.0 'with for loop, instantiate the objects (with set) and 'assign properties For iTask = 0 to iCount-1 Set oSchedule(iTask,0) = oCD.GetSelectbox oSchedule(iTask,0).id = "TeamID" & CStr(iTask+1) oSchedule(iTask,0).className = "Buttons" oSchedule(iTask,0).style= "POSITION: relative; WIDTH: 90px;VERTICAL-ALIGN: top" DisableIfNotTM(oSchedule(iTask,0)) oSchedule(iTask,0).extra = "onChange=""AddUsers(" & "TeamID" & CStr(itask+1) & ".options[" & "TeamID" & CStr(itask+1) & ".selectedIndex].value," & "UserID" & CStr(itask+1) &");""" Set oSchedule(iTask,1) = oCD.GetSelectbox oSchedule(iTask,1).id = "UserID" & CStr(iTask+1) oSchedule(iTask,1).className = "Buttons" oSchedule(iTask,1).style= "POSITION: relative; WIDTH: 90px;VERTICAL-ALIGN: top" 'DisableIfNotTM(oSchedule(iTask,1)) Set oSchedule(iTask,2) = oCD.GetInputbox oSchedule(iTask,2).id = "TargetCompletionDate" & CStr(iTask+1) oSchedule(iTask,2).className = "Buttons" oSchedule(iTask,2).style= "HEIGHT: 17px; WIDTH: 45px; VERTICAL-ALIGN: top" oSchedule(iTask,2).value = rsTasks("TargetCompletionDate") DisableIfNotTM(oSchedule(iTask,2)) oSchedule(iTask,2).extra = "onBlur=""return validateDatesOnBlur(this.value,'Target Date');""" Set oSchedule(iTask,3) = oCD.GetInputbox oSchedule(iTask,3).id = "AssignedDateTime" & CStr(iTask+1) oSchedule(iTask,3).className = "Buttons" oSchedule(iTask,3).style= "HEIGHT: 17px; WIDTH: 45px; VERTICAL-ALIGN: top" oSchedule(iTask,3).value = rsTasks("AssignedDateTime") DisableIfNotTM(oSchedule(iTask,3)) oSchedule(iTask,3).extra = "onBlur=""return validateDatesOnBlur(this.value,'Assigned Date');""" Set oSchedule(iTask,4) = oCD.GetInputbox oSchedule(iTask,4).id = "CompletedDateTime" & CStr(iTask+1) oSchedule(iTask,4).className = "Buttons" oSchedule(iTask,4).style= "HEIGHT: 17px; WIDTH: 45px; VERTICAL-ALIGN: top" oSchedule(iTask,4).value = rsTasks("CompletedDateTime") DisablePopulated oSchedule(iTask,4),rsTasks oSchedule(iTask,4).extra = "onBlur=""return validateDatesOnBlur(this.value,'Completion Date');""" Set oSchedule(iTask,5) = oCD.GetInputbox oSchedule(iTask,5).id = "ReviewedDateTime" & CStr(iTask+1) oSchedule(iTask,5).className = "Buttons" oSchedule(iTask,5).style= "HEIGHT: 17px; WIDTH: 45px; VERTICAL-ALIGN: top" oSchedule(iTask,5).value = rsTasks("ReviewedDateTime") DisableIfNotTM(oSchedule(iTask,5)) oSchedule(iTask,5).extra = "onBlur=""return validateDatesOnBlur(this.value,'Reviewed Date');""" Set oSchedule(iTask,6) = oCD.GetInputbox oSchedule(iTask,6).id = "Hours" & CStr(iTask+1) oSchedule(iTask,6).className = "Buttons" oSchedule(iTask,6).style= "HEIGHT: 17px; WIDTH: 25px; VERTICAL-ALIGN: top" oSchedule(iTask,6).value = rsTasks("Hours") oSchedule(iTask,6).extra = "onBlur=""return validateNumbersOnBlur(this.value,'Hours');""" 'keep running total of Hours column If Not isNull(rsTasks("Hours")) Then fTotalHours = fTotalHours + CSng(rsTasks("Hours")) End If rsTasks.MoveNext Next End If 'end create form elements for tasks 'begin server-side functions '***************************************************** ' ' FUNCTION DISABLEIFNOTTM ' ' Purpose: to disable an object if the user isn't ' a TM ' Inputs: nothing ' Returns: nothing '***************************************************** Function DisableIfNotTM(ByRef oItem) If Session("SecurityProfile") <> "TM" Then oItem.disabled = True End If End Function '***************************************************** ' ' FUNCTION EDITSCHEDULETASK ' ' Purpose: Edits a task ' Inputs: Project Task ID, sequence ' Returns: nothing '***************************************************** Function EditScheduleTask() Dim rsEdit,sFieldName,iFields Set rsEdit = Server.CreateObject("ADODB.Recordset") Dim iProjectTaskID Dim iTaskID iProjectTaskID = Request("ProjectTaskID") iTaskID = Request("iTask") oBS.GetTasks rsEdit,iProjectTaskID If Not isNull(Request("UserID" & CStr(iTaskID))) Then If Request("UserID"& CStr(iTaskID)) <> "" Then rsEdit("UserID") = Request("UserID" & CStr(iTaskID)) Else rsEdit("UserID") = null End If End If 'only TM can update the following fields... If Session("SecurityProfile") = "TM" Then ' update the sequence If isNumeric(Request("Sequence" & CStr(iTaskID))) Then If Request("Sequence" & CStr(iTaskID)) > 0 Then rsEdit("Sequence") = Request("Sequence" & CStr(iTaskID)) End If End If If isNumeric(Request("TeamID" & CStr(iTaskID))) Then rsEdit("TeamID") = Request("TeamID" & CStr(iTaskID)) Else rsEdit("TeamID") = null End If If isDate(Request("AssignedDateTime" & CStr(iTaskID))) Then rsEdit("AssignedDateTime") = Request("AssignedDateTime" & CStr(iTaskID)) Else rsEdit("AssignedDateTime") = null End If If isDate(Request("TargetCompletionDate" & CStr(iTaskID))) Then rsEdit("TargetCompletionDate") = Request("TargetCompletionDate" & CStr(iTaskID)) Else rsEdit("TargetCompletionDate")= null End If If isDate(Request("ReviewedDateTime" & CStr(iTaskID))) Then rsEdit("ReviewedDateTime") = Request("ReviewedDateTime" & CStr(iTaskID)) Else rsEdit("ReviewedDateTime") = null End If End If 'End if TM 'anyone can update Completed Date Time and Hours 'once completion date is populated, it's disabled 'don't let general user write over it. If isDate(Request("CompletedDateTime" & CStr(iTaskID))) Then rsEdit("CompletedDateTime") = Request("CompletedDateTime" & CStr(iTaskID)) Else If Session("SecurityProfile") = "TM" Then rsEdit("CompletedDateTime") = null End If End If If isNumeric(Request("Hours" & CStr(iTaskID))) Then rsEdit("Hours") = Request("Hours" & CStr(iTaskID)) Else rsEdit("Hours") = 0 End If If oBS.UpdateTask(rsEdit) = 0 Then 'Response.Redirect "project_schedule.asp" End If End Function 'end EditScheduleTask() Function '***************************************************** ' ' FUNCTION DELETESCHEDULETASK ' ' Purpose: Deletes a task and updates the schedule ' Inputs: Project Task ID ' Returns: nothing '***************************************************** Function DeleteScheduleTask(iProjectTaskID) If oBS.DeleteTask(CInt(iProjectTaskID)) = 0 Then End If 'Insert some time 'Dim x 'x = Second(Now()) 'If x = 59 Then 'Do While Second(Now()) < 60 And Second(Now()) <> 1 'Loop 'Else 'Do While Second(Now()) < x + 2 'Loop 'End If 'If oBS.UpdateSchedule(CInt(Session("ProjectID")),-1) = 0 Then 'End If 'set session variable so page knows delete was just made Session("hasDeleted") = True Response.Redirect "project_schedule.asp" End Function '***************************************************** ' ' FUNCTION GETPROJECTTYPE ' ' Purpose: Gets the Type Description corresponding ' to a Type ID from the ProjectTypes lookup ' Inputs: ' iTaskIUD: the TypeID ' ' Returns: The Type Description '***************************************************** Function GetProjectType(iTypeID) Dim rs Set rs = Server.CreateObject("ADODB.Recordset") Dim sSQL sSQL = "SELECT * FROM ProjectTypes WHERE TypeID = " & CStr(iTypeID) rs.Open sSQL,"DSN=bsDSN" If Not rs.EOF Then GetProjectType = rs("TypeDescription") End If End Function '***************************************************** ' ' FUNCTION HIGHLIGHTCURRENTTASK ' ' Purpose: If the Task is the current one for ' the project, make the text red ' Inputs: ' iTaskIUD: the ProjectID ' ' Returns: a style string = "COLOR:RED" '***************************************************** Function HighlightCurrentTask(iSequence,iProjectID) Dim rs Set rs = Server.CreateObject("ADODB.Recordset") Dim sSQL sSQL = "SELECT * FROM ProjectTasks WHERE ProjectID = " & CStr(iProjectID) & "and isNull(ReviewedDateTime) order by Sequence" rs.Open sSQL,"DSN=bsDSN" If Not rs.EOF Then If iSequence = rs("Sequence") Then HighlightCurrentTask = "COLOR:RED" End If End If End Function '****************************************************** ' ' FUNCTION UPDATEDATES ' ' Purpose: to update the project start and completion ' dates ' ' Inputs: nothing ' ' Returns: nothing '****************************************************** Function UpdateDates() 'If Request("ProjectStartDate") <> "" Then If isDate(Request("ProjectStartDate")) Then rsProject("ProjectStartDate") = Request("ProjectStartDate") Else rsProject("ProjectStartDate") = null End If 'End If 'If Request("TargetCompletionDate") <> "" Then If isDate(Request("TargetCompletionDate")) Then rsProject("TargetCompletionDate") = Request("TargetCompletionDate") Else rsProject("TargetCompletionDate") = null End If 'End If oBS.UpdateProject rsProject End Function '****************************************************** ' ' FUNCTION CHANGEDATES ' ' Purpose: to update the default schedule dates ' ' Inputs: nothing ' ' Returns: nothing '****************************************************** Function ChangeDates() If oBS.DefaultSchedule(CInt(Session("ProjectID"))) <> 0 Then Response.Redirect("error.asp?msg=defaultschedulenowork") End If End Function '********************************************************************* ' FUNCTION GETNAMEFROMREQUESTERID ' ' Purpose: to obtain First Name and Last Name from a User ID ' ' Input: User ID ' ' Returns: string containing First Name, then Last Name, separated by ' a space '********************************************************************* Function GetNameFromRequesterID(sID) Dim rs Set rs = Server.CreateObject("ADODB.Recordset") Dim sSQL sSQL = "SELECT FirstName,LastName FROM Users WHERE UserID = '" & CStr(sID) & "'" rs.Open sSQL,"DSN=bsDSN" If Not rs.EOF Then GetNameFromRequesterID = rs("FirstName") & " " & rs("LastName") End If rs.Close End Function '********************************************************************* ' FUNCTION SHOWCENTS ' ' Purpose: to display floating point numbers with two decimal places, ' but without dollar-signs (unlike MakeMoney() function) ' ' Input: number ' ' Returns: formatted number '********************************************************************* Function ShowCents(item) If isNumeric(item) Then ShowCents = FormatNumber(item,2) End If End Function %>
| Task | Responsible Team | Responsible Indiv |
Target Start Date |
Assigned | Completed | Reviewed | Hours |