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