Question
grouping output
Hello,
I have tried so many ways of doing this that I have become confused. What I am trying to do is this;
I am reading record for an employee from a database and group them by empl name, then if the date in the record is NOT THURSDAY, write the record to the screen and increment the total hours var by the hrs value and get the next record.
if the date asociated with the record IS thursday write the record, increcment the total hours, write the weekly total, reset the weekly total to 0 ge the next record.
I used <cfif><cfelse> to handle the logic and datepart() to determine the day. This worked to a point. If there are multiple entries for the same thursday they are all written as individual weeks (yes, I know that is what the code says to do) and if the last record in the record set is not thursday I don't get a weekly total.
I tried to address the group of thursday entries by adding a date comparison in there but I couldn't get it to work either (I was missing some thing an could not put my finger on it).
My next shot will be loops, but Im sure which would be the best way to go.
Here is the code, I have modified it tweeked it,ripped sections out and replaced section.
Can someone help me straighten it out.
Thanks, I have another idea I want to try while you all are looking at this.
I have tried so many ways of doing this that I have become confused. What I am trying to do is this;
I am reading record for an employee from a database and group them by empl name, then if the date in the record is NOT THURSDAY, write the record to the screen and increment the total hours var by the hrs value and get the next record.
if the date asociated with the record IS thursday write the record, increcment the total hours, write the weekly total, reset the weekly total to 0 ge the next record.
I used <cfif><cfelse> to handle the logic and datepart() to determine the day. This worked to a point. If there are multiple entries for the same thursday they are all written as individual weeks (yes, I know that is what the code says to do) and if the last record in the record set is not thursday I don't get a weekly total.
I tried to address the group of thursday entries by adding a date comparison in there but I couldn't get it to work either (I was missing some thing an could not put my finger on it).
My next shot will be loops, but Im sure which would be the best way to go.
Here is the code, I have modified it tweeked it,ripped sections out and replaced section.
Can someone help me straighten it out.
<cfparam name="st_hrs" default="0">
<table width="100%" cellspacing="0" cellpadding="3">
<cfoutput query="getDetail" group="staffLname">
<tr>
<td class="lablesW" colspan="4"><strong>#staffLname#, #staffFname# </strong>
<table width="100%">
<tr>
<td width="10%"> </td>
<td width="90%">
<table width="100%">
<tr>
<th scope="col" class="lables" width="25%"><strong>Charge Number</strong></th>
<th scope="col" class="lables" width="12.5%"><strong>Hours</strong></th>
<th scope="col" class="lables" width="12.5%"><strong>CR</strong><strong></th>
<th scope="col" class="lables" width="50%"><strong>Description * </strong></th>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%">
<cfoutput >
<cfif #dayofweek(DatePart('W', wkEndingDTD))# neq 5 ><!---Development Note:: if the day is not THURSADY write the record to the screen--->
<tr>
<td class="lables">
#dateformat(wkEndingDTD, 'mm/dd/yyyy')#
</td>
<td>
<table width="100%" cellspacing="0" cellpadding="3">
<
<tr>
<td scope="row" class="lables" width="25%">#catChrgNum#</td>
<td class="lables" width="12.5%">#hrs#</td>
<td class="lables" width="12.5%">#cr#</td>
<td class="lables" width="50%"><cfif crDscr is '>
#ChrgCat#
<cfelse>
#crDscr#
</cfif><!-- Development Note:: always display a description, either the CR descr OR the charge number -->
</td>
</tr>
</table></td>
</tr>
<cfset T_hrs = #st_hrs# + #hrs# ><!-- Development Note:: sum of hours for the week -->
<cfelse> Development Note:: If the day is Thursday write the record to the screen
<cfif #dayofweek(DatePart('W', wkEndingDTD))# Neq #pdtd#>
<tr>
<td class="lables">#dateformat(wkEndingDTD, 'mm/dd/yyyy')# </td>
<td> <table width="100%" cellspacing="0" cellpadding="3">
<tr>
<td class="lables"width="25%">#catChrgNum#</td>
<td class="lables"width="12.5%">#hrs#</td>
<td class="lables"width="12.5%">#cr#</td>
<td class="lables" width="50%"><cfif crDscr is '>
#ChrgCat#
<cfelse>
#crDscr#
</cfif></td><!-- Development Note:: always display a description, either the CR descr OR the charge number -->
</tr>
</table></td>
</tr>
</cfif>
<cfset T_hrs = #st_hrs# + #hrs# >
<tr>
<td> </td>
<td >
<table width="100%" cellspacing="0" cellpadding="3">
<tr>
<td class="lablesW" width="25%"><strong>Weekly Total </strong></td>
<td class="lablesW"width="12.5%"><strong>#T_hrs#</strong></td>
<td width="12.5%"><strong> </strong></td>
<td width="50%"><strong> </strong></td>
</tr>
</table>
</td>
</tr>
<cfset T_hrs = 0 ><!-- Development Note :: reset weekly total to zero-->
</cfif>
</cfoutput> </table>
</td>
</tr>
Thanks, I have another idea I want to try while you all are looking at this.