home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / full / atlantic / Software / Teweb / data1.cab / Pages / scripts / tsedit.asp < prev    next >
Encoding:
Text File  |  2000-02-14  |  13.1 KB  |  491 lines

  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <%    Set clsTes = Session("TES")
  3.     If clsTes.LoggedIn = False Then
  4.         Set clsTes = Nothing
  5.         Response.Redirect("../loggedout.htm")
  6.     End If
  7.     On Error Resume Next
  8.     tMode=Request("Mode")
  9.     lKey=Request("Key")
  10.     tCode=Request("Code")
  11.     tDesc=Request("Desc")
  12.  
  13.     dDate=Request("Date")
  14.  
  15.     tNotGridBy=Request.Form("txtNotGBCode")
  16.     tHours=Request.Form("txtHours")
  17.     tCostCode=Request.Form("txtCostCode")
  18.     tCostRateAmt=Request.Form("txtCostRateAmt")
  19.     tChargeCode=Request.Form("txtChargeCode")
  20.     tChargeRateAmt=Request.Form("txtChargeRateAmt")
  21.     tNotes=Request.Form("txtNotes")
  22.  
  23.     bOvertime=CInt(Request.Form("chkOvertime"))
  24.     nChargeable=CInt(Request.Form("optChargeable"))
  25.     nCostable=CInt(Request.Form("optCostable"))
  26.     bOverideCost=CInt(Request.Form("chkOverideCost"))
  27.     bOverideCharge=CInt(Request.Form("chkOverideCharge"))
  28.  
  29.     If Err.Number <> 0 Then
  30.         Err.Clear
  31.     End If
  32.  
  33.     If Request.Form("btnCancel") = "Cancel" Then
  34.       Response.Redirect("tsgrid.asp")
  35.     End If
  36.  
  37.     If Request.Form("btnSave") <> "Save Timesheet" Then
  38.         nErrors = 0
  39.         bSave=False
  40.         If tMode="Amend" Then
  41.  
  42.             clsTes.Timesheet.Key = Clng(lKey)
  43.             clsTes.GetTimesheetValues
  44.             If clsTes.GridBy = "Activity" Then
  45.                 tNotGridBy = clsTes.Timesheet.ProjectCode
  46.                 tCode = clsTes.Timesheet.ActivityCode
  47.             Else
  48.                 tNotGridBy = clsTes.Timesheet.ActivityCode
  49.                 tCode = clsTes.Timesheet.ProjectCode
  50.             End If
  51.  
  52.             dDate = clsTes.Timesheet.TimesheetDate
  53.  
  54.             tHours = clsTes.FormatNumber(clsTes.Timesheet.Hours)
  55.             bOvertime = clsTes.Timesheet.Overtime
  56.             tCostCode = clsTes.Timesheet.CostCode
  57.             tChargeCode = clsTes.Timesheet.ChargeCode
  58.             tCostRateAmt = clsTes.Timesheet.CostRate
  59.             tChargeRateAmt = clsTes.Timesheet.ChargeRate
  60.             tNotes = clsTes.Timesheet.Notes
  61.  
  62.             nCostable = -1
  63.             nChargeable = CInt(clsTes.Timesheet.Chargeable)
  64.             bOverideCost = True
  65.             bOverideCharge = nChargeable
  66.  
  67.         Else
  68.  
  69.             'Set up defaults
  70.  
  71.             If clsTes.GridBy = "Activity" Then
  72.                 tNotGridBy = clsTes.DefaultProject
  73.             Else
  74.                 tNotGridBy = clsTes.DefaultActivity
  75.             End If
  76.  
  77.             tCostCode = clsTes.DefaultCost
  78.             tChargeCode = clsTes.DefaultCharge
  79.  
  80.             bOverideCost = False
  81.             bOverideCharge = False
  82.             nChargeable = 1
  83.             nCostable = 1
  84.  
  85.         End If
  86.  
  87.     Else
  88.  
  89.     'Save Mode
  90.  
  91.         bSave = True
  92.         nErrors=0
  93.         tErrorList = "<B>Errors</B>"
  94.  
  95.         If Len(tHours)=0 Then
  96.             nErrors=1
  97.             tErrorList=tErrorList & "<BR>Please enter the number of " & Server.HTMLEncode(clsTes.UnitTimeLabelP)
  98.         Else
  99.             If Not clsTes.IsNumeric(tHours) Then
  100.                 nErrors=1
  101.                 tErrorList=tErrorList & "<BR>Please enter a valid number of " & Server.HTMLEncode(clsTes.UnitTimeLabelP)
  102.             End If
  103.         End If
  104.  
  105.         If bOverideCost and nCostable = -1 Then
  106.             If Len(tCostRateAmt)=0 Then
  107.                 nErrors=1
  108.                 tErrorList=tErrorList & "<BR>Please enter the Cost Rate Amount"
  109.             Else
  110.                 If Not clsTes.IsNumeric(tCostRateAmt) Then
  111.                     nErrors=1
  112.                     tErrorList=tErrorList & "<BR>Please enter a valid Cost Rate Amount"
  113.                 End If
  114.             End If
  115.         End If
  116.  
  117.         If nChargeable=-1 and bOverideCharge Then
  118.             If Len(tChargeRateAmt)=0 Then
  119.                 nErrors=1
  120.                 tErrorList=tErrorList & "<BR>Please enter the Charge Rate Amount"
  121.             Else
  122.                 If Not clsTes.IsNumeric(tChargeRateAmt) Then
  123.                     nErrors=1
  124.                     tErrorList=tErrorList & "<BR>Please enter a valid Charge Rate Amount"
  125.                 End If
  126.             End If
  127.         End If
  128.  
  129.         If Len(tNotes) > 250 Then
  130.             nErrors = 1
  131.             tErrorList=tErrorList & "<BR>Notes must not be more than 250 characters (currently " & CStr(Len(tNotes)) & " characters)"
  132.         End If
  133.  
  134.         If nErrors=0 Then
  135.  
  136.             If clsTes.GridBy = "Project" Then
  137.                 tProject = tCode
  138.                 tActivity = tNotGridBy
  139.             Else
  140.                 tProject = tNotGridBy
  141.                 tActivity = tCode
  142.             End If
  143.  
  144.             If tMode = "Add" Then
  145.                 clsTes.AddTimesheet clsTes.ADbl(dDate),CStr(tProject),CStr(tActivity), CStr(tNotes), clsTes.ADbl(tHours), CInt(bOvertime), CInt(nCostable), CInt(nChargeable), CStr(tCostCode), bOverideCost, tCostRateAmt, CStr(tChargeCode), bOverideCharge, tChargeRateAmt
  146.                 If clsTes.ErrorNumber <> 0 Then
  147.                     nErrors = 1
  148.                     tErrorList = tErrorList & "<BR>" & clsTes.ErrorText
  149.                 Else
  150.                     Response.Redirect("tsgrid.asp")
  151.                 End If
  152.             ElseIf tMode = "Amend" Then
  153.                 clsTes.AmendTimesheet CLng(lKey), clsTes.ADbl(dDate),CStr(tProject),CStr(tActivity), CStr(tNotes), clsTes.ADbl(tHours), CInt(bOvertime), CInt(nCostable), CInt(nChargeable), CStr(tCostCode), bOverideCost, tCostRateAmt, CStr(tChargeCode), bOverideCharge, tChargeRateAmt
  154.                 If clsTes.ErrorNumber <> 0 Then
  155.                     nErrors = 1
  156.                     tErrorList = tErrorList & "<BR>" & Server.HTMLEncode(clsTes.ErrorText)
  157.                 Else
  158.                     Response.Redirect("tsgrid.asp")
  159.                 End If
  160.             End If
  161.  
  162.         End If
  163.  
  164.     End If
  165. %>
  166. <!-- #INCLUDE FILE = "settings/colours.txt" -->
  167. <HTML>
  168. <HEAD>
  169. <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
  170. <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
  171. <TITLE>Edit Timesheet</TITLE>
  172. </HEAD>
  173. <BODY BGCOLOR="<%= BackColor %>" LINK="<%= LinkColor %>" VLINK="<%= VLinkColor %>" ALINK="<%= ALinkColor %>" TEXT="<%= TextColor %>">
  174. <BASEFONT SIZE=2 COLOR="<%= TextColor %>">
  175.  
  176. <FORM ACTION="tsedit.asp" METHOD=POST NAME="frmEdit">
  177. <INPUT TYPE=HIDDEN NAME="Mode" VALUE="<%= tMode %>">
  178. <INPUT TYPE=HIDDEN NAME="Key" VALUE="<%= lKey %>">
  179. <INPUT TYPE=HIDDEN NAME="Code" VALUE="<%= tCode %>">
  180. <INPUT TYPE=HIDDEN NAME="Desc" VALUE="<%= tDesc %>">
  181. <INPUT TYPE=HIDDEN NAME="Date" VALUE="<%= dDate %>">
  182.  
  183. <%    If clsTes.TimesheetMaintainAccess <> 0 Then %>
  184. <CENTER>
  185.     
  186. <FONT SIZE=+2><B>
  187. <%        If tMode="Add" Then
  188.             Response.Write("Add Timesheet")
  189.         Else
  190.             Response.Write("Amend Timesheet")
  191.         End If
  192. %>
  193. </B></FONT>
  194. <P>
  195.  
  196. <%    If tMode="Amend" and Len(Request("Key"))=0 Then %>
  197.         ERROR : No Timesheet supplied to amend
  198.         </FORM>
  199. <%    Else 
  200.         If nErrors Then %>
  201.             <%= tErrorList %>
  202.             <BR><BR>
  203. <%        End If %>
  204.  
  205.  
  206.  
  207. <TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2>
  208.  
  209. <TR>
  210.     <TD ALIGN=LEFT VALIGN=TOP>
  211.         <B><%= Server.HTMLEncode(clsTes.ResourceLabel) %>:</B>
  212.     </TD>
  213.  
  214.     <TD ALIGN=LEFT>
  215.         <%= Server.HTMLEncode(clsTes.Resource) %>
  216.     </TD>
  217. </TR>
  218.  
  219. <TR>
  220.     <TD ALIGN=LEFT VALIGN=TOP>
  221.         <B>Date:</B>
  222.     </TD>
  223.  
  224.     <TD ALIGN=LEFT VALIGN=TOP>
  225. <%            Response.Write(clsTes.FormatLongDate(dDate)) %>
  226.     </TD>
  227. </TR>
  228.  
  229. <TR>
  230.     <TD ALIGN=LEFT VALIGN=TOP>
  231.         <B>
  232. <%            If clsTes.GridBy = "Project" Then %>
  233.                 <%= Server.HTMLEncode(clsTes.ProjectLabel) %>:
  234. <%            Else %>
  235.                 <%= Server.HTMLEncode(clsTes.ActivityLabel) %>:
  236. <%            End If %>        
  237.         </B>
  238.     </TD>
  239.         
  240.     <TD ALIGN=LEFT VALIGN=TOP>
  241. <%            Response.Write(tCode)
  242.             Response.Write(", ") %>
  243. <%        If tMode = "Amend" Then %>
  244.             <%= Server.HTMLEncode(clsTes.GetDescription(CStr(tCode), clsTes.GridBy)) %>
  245. <%        Else %>
  246.             <%= Server.HTMLEncode(tDesc) %>
  247. <%        End If %>
  248.     </TD>
  249. </TR>
  250.  
  251. <TR>
  252.     <TD ALIGN=LEFT>
  253.         <B>
  254. <%        If clsTes.GridBy ="Project" Then 
  255.             tTable = "Activity" %>
  256.             <%= Server.HTMLEncode(clsTes.ActivityLabel) %>:
  257. <%        Else
  258.             tTable = "Projects" %>
  259.             <%= Server.HTMLEncode(clsTes.ProjectLabel) %>:
  260. <%        End If %>
  261.         </B>
  262.     </TD>
  263.  
  264.     <TD ALIGN=LEFT>
  265. <%    clsTes.GenerateDropDownList CStr(tTable),1, CStr(tCode)
  266.     If clsTes.ErrorNumber <> 0 Then
  267.         Response.Write(Server.HTMLEncode(clsTes.ErrorText))
  268.         clsTes.ErrorClear
  269.     End If %>
  270.         <SELECT SIZE=1 NAME="txtNotGBCode">
  271. <%        If tMode = "Amend" Then
  272.             If clsTes.GridBy = "Project" Then %>
  273.                 <%tCurrentNotGridBy = tNotGridBy & "    |    " & clsTes.GetDescription(Trim(tNotGridBy), "Activity") %>
  274.                 <OPTION VALUE="<%= tNotGridBy %>" SELECTED><%= tCurrentNotGridBy %></OPTION>
  275. <%            Else %>
  276.                 <%tCurrentNotGridBy = tNotGridBy & "    |    " & clsTes.GetDescription(Trim(tNotGridBy), "Project") %>
  277.                 <OPTION VALUE="<%= tNotGridBy %>" SELECTED><%= tCurrentNotGridBy %></OPTION>
  278. <%            End If  %>
  279. <%        End If %>
  280.  
  281. <%        If clsTes.UpperBoundRow > 0 Then
  282.             For lRow = 1 To clsTes.UpperBoundRow %>
  283.                 <%If Not (tNotGridBy = clsTes.GridValue(lRow,0) and tMode = "Amend") Then%>
  284.                     <OPTION VALUE="<%= Server.HTMLEncode(clsTes.GridValue(lRow, 0)) %>" <% If tNotGridBy = clsTes.GridValue(lRow,0) and tMode <> "Amend" Then Response.Write("SELECTED") %>><%= clsTes.GridValue(lRow,1) %></OPTION>
  285.                 <%End IF%>
  286. <%            Next
  287.         End If %>
  288.         </SELECT>
  289.     </TD>
  290. </TR>
  291.  
  292. <TR>
  293.     <TD ALIGN=LEFT>
  294.         <B>
  295.         <%= Server.HTMLEncode(clsTes.UnitTimeLabelP) %>:
  296.         </B>
  297.     </TD>
  298.     <TD ALIGN=LEFT>
  299.         <INPUT TYPE=TEXT MAXLENGTH=20 NAME="txtHours" VALUE="<%= tHours %>" SIZE=20>
  300.     </TD>
  301. </TR>
  302.  
  303.  
  304. <%        If clsTes.UserOvertime Then %>
  305. <TR>
  306.     <TD></TD>
  307.     <TD ALIGN=LEFT VALIGN=TOP>
  308.         <INPUT TYPE=CHECKBOX NAME="chkOvertime" VALUE=-1 <%If bOvertime Then Response.Write("CHECKED") %>>
  309.         Overtime
  310.     </TD>
  311. </TR>
  312. <%        Else %>
  313.     <INPUT TYPE=HIDDEN NAME="chkOvertime" VALUE=<%= bOvertime %>>
  314. <%        End If %>
  315.  
  316. <%        If clsTes.UserCost <> 0 Then    'UT_COST_NONE %>
  317. <TR>
  318.     <TD ALIGN=LEFT VALIGN=TOP>
  319.         <B>
  320.         Cost:
  321.         </B>
  322.     </TD>
  323.  
  324.     <TD ALIGN=LEFT VALIGN=TOP>
  325.         <TABLE BORDER=1 CELLSPACING=0>
  326.         <TR>
  327.  
  328. <%        If clsTes.UserCost = 1 or clsTes.UserCost = 2 Then    'UT_COST_VIEW_CODE or UT_COST_VIEW_CODE_AMT %>
  329.             <TD COLSPAN=2>
  330.                 <%= Server.HTMLEncode(tCostCode) %>
  331.             </TD>
  332.             <INPUT TYPE=HIDDEN NAME="optCostable" VALUE=<%= nCostable %>>
  333. <%        Else %>
  334.             <TD COLSPAN=3>
  335.                 <INPUT TYPE=RADIO NAME="optCostable" VALUE=1 <% If nCostable=1 Then Response.Write("CHECKED") %>>
  336.                 Default
  337.             </TD>
  338.         </TR>
  339.  
  340.         <TR>
  341.             <TD ROWSPAN=2>
  342.                 <INPUT TYPE=RADIO NAME="optCostable" VALUE=-1 <% If nCostable=-1 Then Response.Write("CHECKED") %>>
  343.                 Specify
  344.             </TD>
  345.  
  346.             <TD COLSPAN=2>
  347.  
  348. <%                clsTes.GenerateDropDownList "Cost",1
  349.                 If clsTes.ErrorNumber <> 0 Then
  350.                     Response.Write(clsTes.ErrorText)
  351.                 clsTes.ErrorClear
  352.                 End If %>
  353.                 <SELECT SIZE=1 NAME="txtCostCode">
  354. <%                If clsTes.UpperBoundRow > 0 Then
  355.                     For lRow = 1 To clsTes.UpperBoundRow %>
  356. <OPTION VALUE="<%= Server.HTMLEncode(clsTes.GridValue(lRow, 0)) %>" <% If StrComp(tCostCode,clsTes.GridValue(lRow,0))=0 Then Response.Write("SELECTED") %>><%= clsTes.GridValue(lRow,1) %></OPTION>
  357. <%                    Next
  358.                 End If %>
  359.                 </SELECT>
  360.             </TD>
  361. <%        End If%>
  362.  
  363.  
  364. <%        If clsTes.UserCost = 4 Then        'US_COST_MAINTAIN_CODE_AMT %>
  365.         <TR>
  366.             <TD>
  367.                 <INPUT TYPE=CHECKBOX NAME="chkOverideCost" VALUE=-1 <% If bOverideCost=-1 Then Response.Write("CHECKED") %>>
  368.                 Override cost rate amount
  369.             </TD>
  370.     
  371.             <TD>
  372.                 <INPUT TYPE=TEXT NAME="txtCostRateAmt" VALUE="<%= tCostRateAmt %>" SIZE=10 MAXLENGTH=20>
  373.             </TD>
  374.         </TR>
  375. <%        Else %>
  376.         <INPUT TYPE=HIDDEN NAME="chkOverideCost" VALUE=0>
  377. <%        End If %>
  378.         </TABLE>
  379.     </TD>
  380.  
  381. </TR>
  382. <%        End If %> 
  383.  
  384.  
  385.  
  386. <%        If clsTes.UserChargeableTimesheet = 2 Then    'UT_CHARGEABLE_TS_MAINTAIN %>
  387. <TR>
  388.     <TD ALIGN=LEFT VALIGN=TOP>
  389.         <B>
  390.         Charge:
  391.         </B>
  392.     </TD>
  393.  
  394.     <TD>
  395.         <TABLE BORDER=1 CELLSPACING=0>
  396.         <TR>
  397.             <TD NOWRAP=NOWRAP COLSPAN=3>
  398.                 <INPUT TYPE=RADIO NAME="optChargeable" VALUE=0 <% If nChargeable=0 Then Response.Write("CHECKED") %>>Non-Chargeable
  399.             </TD>
  400.         </TR>
  401.         <TR>
  402.             <TD NOWRAP=NOWRAP COLSPAN=3>
  403.                 <INPUT TYPE=RADIO NAME="optChargeable" VALUE=1 <% If nChargeable=1 Then Response.Write("CHECKED") %>>Default
  404.             </TD>
  405.         </TR>
  406. <%        If clsTes.UserCharge > 2 Then %>
  407.         <TR>
  408.             <TD NOWRAP=NOWRAP ROWSPAN=2>
  409.                 <INPUT TYPE=RADIO NAME="optChargeable" VALUE=-1 <% If nChargeable=-1 Then Response.Write("CHECKED") %>>Chargeable
  410.             </TD>
  411.             <TD ALIGN=LEFT VALIGN=TOP COLSPAN=2>
  412. <%            clsTes.GenerateDropDownList "Charge", 1
  413.             If clsTes.ErrorNumber <> 0 Then
  414.                 Response.Write(clsTes.ErrorText)
  415.                 clsTes.ErrorClear
  416.             End If %>
  417.                 <SELECT SIZE=1 NAME="txtChargeCode">
  418. <%        If clsTes.UpperBoundRow > 0 Then
  419.             For lRow = 1 To clsTes.UpperBoundRow %>
  420. <OPTION VALUE="<%= Server.HTMLEncode(clsTes.GridValue(lRow, 0)) %>" <% If tChargeCode = clsTes.GridValue(lRow,0) Then Response.Write("SELECTED") %>><%= clsTes.GridValue(lRow,1) %></OPTION>
  421. <%            Next
  422.         End If %>
  423.                 </SELECT>
  424.             </TD>
  425.         </TR>
  426. <%        Else %>
  427.         <TR>
  428.             <TD NOWRAP=NOWRAP COLSPAN=3>
  429.                 <INPUT TYPE=RADIO NAME="optChargeable" VALUE=-1 <% If nChargeable=-1 Then Response.Write("CHECKED") %>>Chargeable
  430.             </TD>
  431.         </TR>
  432. <%        End If %>
  433.  
  434.  
  435. <%        If clsTes.UserCharge = 4 Then    'UT_MAINTAIN_CODE_AMT %>
  436.         <TR>
  437.             <TD>
  438.                 <INPUT TYPE=CHECKBOX NAME="chkOverideCharge" VALUE=-1 <% If bOverideCharge=-1 Then Response.Write("CHECKED") %>>
  439.                 Override charge rate amount
  440.             </TD>
  441.     
  442.             <TD>
  443.                 <INPUT TYPE=TEXT NAME="txtChargeRateAmt" VALUE="<% Response.Write(tChargeRateAmt) %>" SIZE=10 MAXLENGTH=20>
  444.             </TD>
  445.         </TR>
  446. <%        Else %>
  447.         <INPUT TYPE=HIDDEN NAME="chkOverideCharge" VALUE=0>
  448. <%        End If %>
  449.         </TABLE>
  450.     </TD>
  451. </TR>
  452. <%        Else %>
  453. <INPUT TYPE=HIDDEN NAME="optChargeable" VALUE=<%= nChargeable %>>
  454. <INPUT TYPE=HIDDEN NAME="chkOverideCharge" VALUE=0>
  455. <%        End If %>
  456.  
  457. <%        If clsTes.UserTimesheetNotes Then %>
  458. <TR>
  459.     <TD VALIGN=TOP ALIGN=LEFT>
  460.         <B>
  461.         Notes:
  462.         </B>
  463.     </TD>
  464.  
  465.     <TD>
  466.         <TEXTAREA COLS=50 ROWS=2 NAME="txtNotes"><%= Server.HTMLEncode(tNotes) %></TEXTAREA>
  467.     </TD>
  468. </TR>
  469. <%        Else %>
  470.         <INPUT TYPE=HIDDEN NAME="txtNotes" VALUE="<%= tNotes %>">
  471. <%        End If %>
  472.  
  473. <TR>
  474.     <TD COLSPAN=2 ALIGN=CENTER>
  475.     <INPUT TYPE=SUBMIT NAME="btnSave" VALUE="Save Timesheet">
  476.     <INPUT TYPE=SUBMIT NAME="btnCancel" VALUE="Cancel">
  477.     </TD>
  478. </TR>
  479.  
  480. </TABLE>
  481.  
  482. <%    End If %>
  483.  
  484. <%    Else %>
  485. Sorry, you do not have permission to maintain timesheets.
  486. <%    End If %>
  487.  
  488. <% Set clsTes = Nothing %>
  489. </BODY>
  490. </HTML>
  491.