<!---
Name:        results.cfm
Author:      David Golden (d_golden73@hotmail.com)
Description: results page
Created:     5/01/01
--->
<cfinclude template="Connections/connOWS.cfm">
<cfparam name="FORM.FilmSelection" default="1">
<cfparam name="GetMovieTitle__MMColParam" default="#FORM.FilmSelection#">
<cfquery name="GetMovieTitle" datasource=#MM_connOWS_DSN# username=#MM_connOWS_USERNAME# password=#MM_connOWS_PASSWORD#>
SELECT FilmID, MovieTitle, AmountBudgeted FROM Films WHERE FilmID = #GetMovieTitle__MMColParam# 
</cfquery>
<cfparam name="GetTotalExpenses__MMColParam" default="#FORM.FilmSelection#">
<cfquery name="GetTotalExpenses" datasource=#MM_connOWS_DSN# username=#MM_connOWS_USERNAME# password=#MM_connOWS_PASSWORD#>
SELECT SUM(ExpenseAmount) AS TotalExpense FROM Expenses WHERE FilmID = #GetTotalExpenses__MMColParam# 
</cfquery>
<cfscript> MM_paramName = ""; 
</cfscript>
<cfscript>
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

// create the list of parameters which should not be maintained
MM_removeList = "&index=";
If (MM_paramName NEQ "") MM_removeList = MM_removeList & "&" & MM_paramName & "=";
MM_keepURL=""; MM_keepForm=""; MM_keepBoth=""; MM_keepNone="";

// add the existing URL parameters to the MM_keepURL string
MM_params=ListToArray(CGI.QUERY_STRING,"&");
For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
  If (FindNoCase("&" & GetToken(MM_params[i],1,"=") & "=",MM_removeList) Is 0)
    MM_keepURL = MM_keepURL & "&" & MM_params[i];
}

// add the existing Form variables to the MM_keepForm string
If (IsDefined("FORM.FieldNames")) {
  MM_params=ListToArray(FORM.FieldNames,",");
  For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
    If (FindNoCase("&" & MM_params[i] & "=",MM_removeList) Is 0)
      MM_keepForm = MM_keepForm & "&" & LCase(MM_params[i]) & "=" & URLEncodedFormat(Evaluate("FORM." & MM_params[i]));
  }
}

// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm;
If (MM_keepURL NEQ "") MM_keepURL = RemoveChars(MM_keepURL,1,1);
If (MM_keepForm NEQ "") MM_keepForm = RemoveChars(MM_keepForm,1,1);
If (MM_keepBoth NEQ "") MM_keepBoth = RemoveChars(MM_keepBoth,1,1);
</cfscript>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="50%" border="1" cellspacing="2" cellpadding="2">
  <tr> 
    <td colspan="2"><b><cfoutput>#GetMovieTitle.MovieTitle#</cfoutput></b></td>
  </tr>
  <tr> 
    <td>Current Total Expenses</td>
    <td><A HREF="details.cfm?<cfoutput>#Trim(MM_keepNone & Iif(MM_keepNone NEQ '',DE('&'),DE('')) & 'FilmID=' & GetMovieTitle.FilmID)#</cfoutput>"><cfoutput># DollarFormat(GetTotalExpenses.TotalExpense) #</cfoutput></A></td>
  </tr>
  <tr> 
    <td>Total Budget</td>
    <td><cfoutput># DollarFormat(GetMovieTitle.AmountBudgeted) #</cfoutput></td>
  </tr>
  <tr> 
    <td height="26" colspan="2"><i><font size="2">To see individual expenses, 
      click total expenses value.</font></i></td>
  </tr>
</table>
</body>
</html>


