[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calculate WEEK number within a CFFORM

Posted on 2006-04-18
2
Medium Priority
?
785 Views
Last Modified: 2013-12-24
I have a form that collects employee daily project logs and hours and posts them to a SQL table that is linked to the project table. I would like to add a small table off to the side that shows the total hours that the employee has entered into the db for TODAY, THIS WEEK, and LAST WEEK. The date of the log is entered by the employee in a form field called ContactDate. The default on the ContactDate field is today's date.
My first idea was to create a trigger that posted the week number to a field in the SQL table, but I couldn't figure out how to convert the javascript I found into something I could use in SQL.

My next idea was to calculate the week number before the entry form is submitted (using a postback kind of idea). I could then query the db for the employee's name and sum for all hour entries for today (easy to do), this week (calculate today's week number and query for this number in the db), and last week (same method but query for this week's number -1).

However, I am stuck on the execution. If I put in a hidden field and call the #form.ContactDate#, it croaks and says it is undefined.

Here is the script I found to do the calculate week number:
******************************************************
function getWeekNumber(d1)
{
      var month = Date.getMonth(d1);
      var day = Date.getDay(d1);
      var year = Date.getYear(d1);
      
      var now = new Date(year, month, day + 1);
      var then = new Date(year, 0, 1);
      var firstDay = new Date(year, 0, 1);      
      var compensation = firstDay.getDay() + 3;      
      return Math.round((((now - then) / 86400000) + compensation) / 7);
}
******************************************************

Here is the main form code which all works fine - except now I want to add the additional information in a table at the top right of the page. I don't know if anyone will need this to help answer my question but here it is:


===================================================================
<cfset LogProjectSelected ="Yup" />
<cfset LogProjectNumber = '#getProjects.ProjectNumber#' />
<cfform action ="MapRequest_LogAction.cfm?ProjectNumber=#myProjectNumber#" name="LogEntry" method="Post" enctype="multipart/form-data">
<cfoutput>
    <input type="hidden" name="CreateDate" value="#DateFormat(Now())#"/>
</cfoutput>

      <select name="ProjectNumber" style="width:450px; text-align:left ">
        <cfoutput query="getProjects">
          <option value=#ProjectNumber#>#ProjectNumber# [#ProjectTitle#] - (CustomerName#)</option>
        </cfoutput> <cfoutput query="getAllProjects">
          <option value=#ProjectNumber#>#ProjectNumber#[#ProjectTitle#] - (#CustomerName#)</option>
        </cfoutput>
      </select>
  <!--- THIS IS THE FIELD WHERE THEY SELECT THEIR NAME --->    
    <select name="StaffName" style="font-size:medium; color:#006699; ">
        <cfoutput>
             <option value="#getProjects.staffnameassign#">#getProjects.staffnameassign#</option>
        </cfoutput>
             <option value="Joe">Joe</option>
             <option value="Jim">Jim</option>
             <option value="Tom">Tom</option>
      </select>
<!---THIS IS THE DATE FIELD IN QUESTION --->
<input type="text" value="<cfoutput>#DateFormat(prestime, "mm/dd/yyyy")#</cfoutput>" name="ContactDate" required="no" size="10" style="text-align:left; vertical-align:middle; color:#CC3300; font-size:medium" />
      <a href="javascript:show_calendar('LogEntry.ContactDate');" onMouseOver="window.status='Date Picker';return true;" onMouseOut="window.status='';return true;"><img border=0 src="NewMapRequest/images/calendar_icon.gif" align="absbottom"></a>
<!---THIS IS THE HOURS FIELD THAT COLLECTS THE HOURS --->
<input name="hrs" type="text" style="font-size:large; color:CC3300; width:100; font-weight:bold;">
      </input>

<textarea name="LogNotes" cols="45" rows="8"></textarea>

<input type="submit" value="Submit Log Entry" onMouseDown="">
<input type="reset" value="Reset Form">
===================================================================

I am interested in any way to accomplish my goal... total hours by week for this week and last week.
SQL - COLDFUSION - JAVASCRIPT - or whatever... I have no preference.

Bauerchick
0
Comment
Question by:Bauerchick
2 Comments
 

Author Comment

by:Bauerchick
ID: 16483818
Can I use something like DATEPART(ww, ContactDate) inside a trigger?
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 2000 total points
ID: 16483944
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question