you asked for it :)

<cfcomponent displayName="dpv1WebReports" hint="DPV1 Raw Data Web Reports">

        <cffunction name="stopsAndIgnitions" access="public" output="1"
returntype="query">
        
                <cfargument name="ipAddressNumber" type="numeric"
required="Yes"/>                                 
                <cfargument name="beginDateTime" type="date"
required="Yes"/>                        
                <cfargument name="endDateTime" type="date" required="Yes"/>

                <cfset var get = 0>
                <cfset var usedArray = arrayNew(1)>
                <cfset var stopTimeArray = arrayNew(1)>
                <cfset var arrayValues = 0>
                <cfset var addColumn = 0>
                <cfset var stopTimeBegin = 0>
                <cfset var stopTimeEnd = 0>
                <cfset var stopTime = 0>
                <cfset var stopTimeSet = 0>
                <cfset var used = 0>            
                <cfset var i = 1>                               
                <cfset var x = 1>
                
                <cfquery name = "get" datasource = "dpv1">
                        select *
                        from reportsView r
                        inner join vehicleTable v
                        on v.ipAddressNumber = r.ipAddressNum
                        where r.ipAddressNum = #arguments.ipAddressNumber#
                        and r.currentDate between
'#arguments.beginDateTime#' and '#arguments.endDateTime#'
                        order by currentDate asc
                </cfquery>
                
                <cfif not get.recordCount>
                        <cflocation url="new_vehicleReport.cfm">
                </cfif>
                        
                <cfset arrayValues =
arraySet(usedArray,1,get.recordCount,0)>
                <cfset addColumn = queryAddColumn(get,'used',usedArray)>
                
                <cfset arrayValues =
arraySet(stopTimeArray,1,get.recordCount,0)>
                <cfset addColumn =
queryAddColumn(get,'stopTime',stopTimeArray)>
                
                        <cfloop from = 1 to = #get.recordCount# index = i>
                
                                <cfparam name="previousSpeed" default="">
                
                                        <cfset this = i>
                                        <cfset next = i + 1>
                                        <cfset previous = i - 1>
                                        <!--- <cfset used =
querySetCell(get,'used',0,i)>            --->                           
                                        
                                                <cfif
((get.currentIgnition[i] eq 0) or (get.speed[i] eq 0)) and (i neq
get.recordCount) and (get.used[i] neq 1)>
        
                                                        <cfset stopTimeBegin
= get.timeId[i]>
                                                        <!--- <cfset used =
querySetCell(get,'used',0,i)>    --->                                   
                                                                
                                                                <cfloop from
= #i# to = #get.recordCount# index = x>
                                                                        
        
<cfif get.speed[x] gt 0>
                                                                        
        
<cfset used = querySetCell(get,'used',0,x)>

        
<cfset stopTimeEnd = get.timeId[x]>
        
<cfbreak>
        
        
<cfelseif get.currentIgnition[x] gt 0>
                                                                        
        
<cfset used = querySetCell(get,'used',0,x)>

        
<cfset stopTimeEnd = get.timeId[x]>
        

        
<cfif (isDefined("stopTimeBegin") and stopTimeBegin) and
(isDefined("stopTimeEnd") and stopTimeEnd)>
        
<cfset stopTime = stopTimeEnd - stopTimeBegin>
        
</cfif>

        

        
<cfset stopTimeSet = querySetCell(get,'stopTime',stopTime,i)>

        

        
<cfbreak>

        

        
<cfelseif get.currentIgnition[x] eq 0 and (x eq get.recordCount)>
                                                                        
        
<cfset used = querySetCell(get,'used',0,x)>

        
<cfset stopTimeEnd = get.timeId[x]>
        

        
<cfif (isDefined("stopTimeBegin") and stopTimeBegin) and
(isDefined("stopTimeEnd") and stopTimeEnd)>
        
<cfset stopTime = stopTimeEnd - stopTimeBegin>
        
</cfif>

        

        
<cfset stopTimeSet = querySetCell(get,'stopTime',stopTime,x)>
        

        
<cfbreak>

                                                                        
        
<cfelse>
        

        
<cfif (get.previousIgnition[x] eq 0)>
        
<cfset used = querySetCell(get,'used',1,x)>

        
</cfif>
                                        
        
</cfif>
        
                                                                </cfloop>
                                                        
                                                <cfelseif
((get.currentIgnition[i] eq 0) or (get.speed[i] eq 0)) and (i eq 1)>
        
                                                        <cfset stopTimeBegin
= get.timeId[i]>
                                                        <cfset used =
querySetCell(get,'used',0,i)>
                                                                
                                                <cfelseif
((get.currentIgnition[i] eq 0) or (get.speed[i] eq 0)) and (i neq
get.recordCount) and (get.used[i] neq 1)>
                                                
                                                        <cfset stopTimeBegin
= get.timeId[i]>
                                                        <cfset used =
querySetCell(get,'used',0,i)>                   
                                                                
                                                <cfelseif
((get.currentIgnition[i] eq 0) or (get.speed[i] eq 0)) and (i eq
get.recordCount) and (get.used[i] neq 1)>
                                                
                                                        <cfset stopTimeEnd =
get.timeId[i]>
                                                        
                                                        <cfif
(isDefined("stopTimeBegin") and stopTimeBegin) and (isDefined("stopTimeEnd")
and stopTimeEnd)>
                                                                <cfset
stopTime = stopTimeEnd - stopTimeBegin>
                                                        </cfif>

                                                        
                                                        <cfset used =
querySetCell(get,'used',0,i)>

                                                        <cfset stopTimeSet =
querySetCell(get,'stopTime',stopTime,i)>

                        
                                                </cfif>
                                
                                <cfset previousSpeed = get.speed[i]>    
                                <cfset stopTimeBegin = 0>
                                <cfset stopTimeEnd = 0>

                                <cfset stopTime = 0>

                                                        
                </cfloop>
        
                <cfreturn get>
                                
        </cffunction>
                
</cfcomponent>
                
                

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to