Solved

Classic ASP, IIS 8 with SQL Server 2008 Express - one page keeps logging the user out on page load

Posted on 2015-02-09
20
145 Views
Last Modified: 2015-02-11
HI,

I have a strange problem. Had a stable, well-running classic ASP application on an older Win 2008 web server that failed.

We recovered the database and application files and deployed them on a new Windows 2012 server (no choice, long story).

The application seems to be working, but there is one page - a critical page - that appears to be killing the user session state on page load. So when the user goes to save their form submittal, they just get the login page. This is true even if they just go to this page, and hit refresh.

Has anyone heard of this sort of thing? Other pages, presumably with more complicated programming are writing, modifying and deleting records as expected, but this one page no longer lets us do anything.

I've attached the page. (Actually it wouldn't let me attach ASP file - sorry for the long code paste:

<%@LANGUAGE="VBSCRIPT"%>
<%
' functions are typically at the top or bottom of your page.
function checkIT(user_type,valueToCheckInclude, valueToCheckExclude)
     checkInclude=false
     checkExclude=true
     arrUsertype=split(user_type,",")
     for each number in arrUsertype
          if cstr(number)=cstr(valueToCheckInclude) then
               checkInclude=true
         end if
         if cstr(number)=cstr(valueToCheckExclude) then
               checkExclude=false
         end if

    next
    if checkInclude = true And checkExclude = true then
     checkIT = true
   else
     checkIT = false
   End if
end function

function checkIT2(user_type2,valueToCheckInclude2, valueToCheckExclude2)
user_type2=replace(user_type2," ","")
	if instr(","& user_type2 &",",","& valueToCheckInclude2 &",")>0 AND instr(","& user_type2 &",",","& valueToCheckExclude2 &",")=0 then
		checkIT2=True
	else
		checkIT2=False
	end if
end function
%>
<!--#include file="Connections/mande2.asp" -->
<%
set oCon = server.CreateObject("ADODB.Connection")
    oCon.open MM_mande_STRING
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="login_redirect.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If

Dim UserRegion
Dim UserRegion_cmd
Dim UserRegion_numRows

Set UserRegion_cmd = Server.CreateObject ("ADODB.Command")
UserRegion_cmd.ActiveConnection = MM_mande_STRING
UserRegion_cmd.CommandText = "SELECT * FROM Regions where clientid = "&Session("clientid")&"  ORDER BY regionname DESC" 
UserRegion_cmd.Prepared = true

Set UserRegion = UserRegion_cmd.Execute
UserRegion_numRows = 0
%>

<%
Dim User__MMColParam
User__MMColParam = "1"
If (Session("MM_Username") <> "") Then 
  User__MMColParam = Session("MM_Username")
End If
%>
<%
Dim User
Dim User_cmd
Dim User_numRows

Set User_cmd = Server.CreateObject ("ADODB.Command")
User_cmd.ActiveConnection = MM_mande_STRING
User_cmd.CommandText = "SELECT * FROM Users WHERE clientid = "&Session("clientid")&" and  UserName = ?" 
User_cmd.Prepared = true
User_cmd.Parameters.Append User_cmd.CreateParameter("param1", 200, 1, 255, User__MMColParam) ' adVarChar

Set User = User_cmd.Execute
User_numRows = 0
%>
<%
Dim summary
Dim summary_cmd
Dim summary_numRows

Set summary_cmd = Server.CreateObject ("ADODB.Command")
summary_cmd.ActiveConnection = MM_mande_STRING
summary_cmd.CommandText = "SELECT Users.UserID, Users.UserFirstName, Sum(Jobs.AcceptedPrice) AS SumOfsalevalue, Avg(Jobs.AcceptedPrice) AS AvgOfsalevalue FROM Users INNER JOIN Jobs ON Users.UserID = Jobs.EstimatorAssigned GROUP BY users.userid, Users.UserFirstName" 
summary_cmd.Prepared = true

Set summary = summary_cmd.Execute
summary_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
summary_numRows = summary_numRows + Repeat1__numRows
%>
      
<!doctype html>
<html xml:lang="en-gb" lang="en-gb" >
<head>
			<meta name="viewport" content="width=device-width, initial-scale=1.0">
        <%
set which = oCon.execute("SELECT Server FROM Which")
%>

<% whichserver=(which("Server"))%>
  <base href="<% =whichserver %>" />
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title><%=session("compname")%> Powered by Simple Source CRM v4</title>
  <link href="<% =whichserver %>" rel="canonical" />

  <link rel="stylesheet" href="/templates/rt_stratos/css-compiled/menu-296f9540b6fdbc3d0fa92e37d50106a1.css" type="text/css" />
  <link rel="stylesheet" href="/libraries/gantry/css/grid-responsive.css" type="text/css" />
  <link rel="stylesheet" href="/templates/rt_stratos/css-compiled/bootstrap.css" type="text/css" />
  <link rel="stylesheet" href="/templates/rt_stratos/css-compiled/master-10d632fb5e871d124a63de7b89359a4a.css" type="text/css" />
  <link rel="stylesheet" href="/templates/rt_stratos/css-compiled/mediaqueries.css" type="text/css" />

  <link rel="stylesheet" href="/templates/rt_stratos/css/rt_stratos-custom.css" type="text/css" />
  <style type="text/css">
#rt-logo {background: url(/images/logo_final2.png) 50% 0 no-repeat !important;}
#rt-logo {width: 350px;height: 45px;}
.rt-grid-6 {width: 370px;}
.icon-help-huge:before  {color:#333;}
@media (max-width: 480px) { 
#rt-mainbody {margin-top:-100px;}
 }

/* Smartphones to Tablets */
@media (min-width: 481px) and (max-width: 767px) {
#rt-mainbody {margin-top:-100px;}
 }

/* Tablets */
@media (min-width: 768px) and (max-width: 959px) { 
.menu-block{width:960px;}
 }

/* Desktop */
@media (min-width: 960px) and (max-width: 1199px) { 
.menu-block{width:1100px;}
}

/* Large Display */
@media (min-width: 1200px) { 
.menu-block{width:1100px;}
 }

  </style>
  <script src="/media/system/js/mootools-core.js" type="text/javascript"></script>
  <script src="/media/system/js/core.js" type="text/javascript"></script>
  <script src="/media/system/js/mootools-more.js" type="text/javascript"></script>
  <script src="/plugins/system/rokbox/assets/js/rokbox.js" type="text/javascript"></script>

  <script src="/templates/rt_stratos/js/rokmediaqueries.js" type="text/javascript"></script>
  <script src="/modules/mod_roknavmenu/themes/default/js/rokmediaqueries.js" type="text/javascript"></script>
  <script src="/modules/mod_roknavmenu/themes/default/js/responsive.js" type="text/javascript"></script>
  <script type="text/javascript">
if (typeof RokBoxSettings == 'undefined') RokBoxSettings = {pc: '100'};

  </script>
  <script type="text/javascript">
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
</script>
<script>
function changeColour(elementId) {
    var interval = 1000;
    var colour1 = "#ff0000"
    var colour2 = "#000000";
    if (document.getElementById) {
        var element = document.getElementById(elementId);
        //element.style.color = (element.style.color == colour1) ? colour2 : colour1;
        setTimeout("changeColour('" + elementId + "')", interval);
    }
}
//-->
</script>
	




 

</head>
<body  onLoad="changeColour('flashtext')" class="logo-type-custom background-overlay-light background-type-light-diagonal-strips header-overlay-dark main-body-light font-family-stratos font-size-is-default menu-type-dropdownmenu layout-mode-responsive col12 option-com-content menu-sign-up ">
<div id="bodyFilm"></div>



<input type="hidden" name="HUserType" id="HUserType" value="<%=Session("UserType")%>"  />

	<div id="rt-page-surround">
				<header id="rt-top-surround">
						<div id="rt-drawer">
				<div class="rt-container">
										<div class="clear"></div>
				</div>
			</div>
						
									<div id="rt-header">
				<div class="rt-container">
					<div class="rt-grid-6 rt-alpha">
            <div class="rt-block logo-block">
            <%
			set rs = oCon.Execute("select CompanyLogoImage FROM GlobalSettings where clientid = "&Session("clientid") & " "  )
			If IsNull(rs("CompanyLogoImage")) OR rs.eof Then
			%>
            <a href="index.asp"> <img src="images/logo_final5.png" alt="Click for Home Page" style="height:45px;"  /></a>
            
            <% ELSE %>
            <a href="index.asp"><img src="img/<%=session("complogo")%>" alt="Click for Home Page" style="height:45px;"  /></a>
            
            <% END IF %>
        </div>
        
</div>
<br><br><br>




    	<div class="rt-block menu-block">
        
		<div class="gf-menu-device-container"></div>
<ul class="gf-menu rt-desktop-menu l1 " >
                    <li class="item108" >

            <a class="item icon" href="index.asp"  >

                                <span class="icon-home"></span><span class="menu-text">Home</span>            </a>


            
                                   
                                    </li>
                                    
                    <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"2")) OR (instr(Session("UserTypes"),"7")) THEN %>                 
             <li class="item117 active last" >

            <a class="item icon" href="javascript:void(0);"  >

                                <span class="icon-quote-right"></span><span class="menu-text">Bids</span>            </a>
  <div class="dropdown columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l2">
                              <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"7")) THEN %>                                                                                          <li class="item1090" >

            <a class="item" href="search_customer.asp"  >
<span class="icon-search"></span><span class="menu-text"> Search Customers</span>
                                           </a>


                    </li>
                                                                             
                                                                             
<li class="item2090" >

            <a class="item" href="add_job.asp"  >
<span class="icon-calendar"></span><span class="menu-text"> Schedule Bids</span>
                                           </a>


                    </li>                                                                                                                        <li class="item1100" >

            <a class="item" href="leads_manager.asp"  >
<span class="icon-phone"></span><span class="menu-text"> Manage Leads</span>
                                           </a>

                    </li>
                          <% END IF %>  
                          
                           <% IF checkIT2(Session("UserTypes"),"2","1") AND checkIT2(Session("UserTypes"),"2","7") THEN %>
                            <li class="item1090" >

            <a class="item" href="search_customer2.asp"  >
<span class="icon-search"></span><span class="menu-text"> Search Customers</span>
                                           </a>


                    </li>
                           <li class="item2090" >

            <a class="item" href="add_job2.asp"  >
<span class="icon-calendar"></span><span class="menu-text"> Schedule Bids</span>
                                           </a>


                    </li>
                           
                           <% END IF %>
                                                    <% IF (instr(Session("UserTypes"),"2"))  THEN %>                                                       
                      
                    <li class="item2100" >

            <a class="item" href="estimate_manager_created_estimator.asp"  >
<span class="icon-wrench"></span><span class="menu-text"> Manage My Bids</span>
                                           </a>

                    </li>
<% end if%>                            
                                                                                                        </ul>
                        </div>
                                            </div>


            </li>
            
            <% END IF %>
                          
                          
 <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"3")) OR (instr(Session("UserTypes"),"7")) OR (instr(Session("UserTypes"),"8")) THEN %>          
                 <li class="item117" >

            <a class="item icon" href="javascript:void(0);"  >

                                <span class="icon-truck"></span><span class="menu-text">Jobs</span>            </a>
  <div class="dropdown columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l2">
                              
                    

          <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"7")) OR (instr(Session("UserTypes"),"8")) THEN %>                                             <li class="item4090" >

            <a class="item" href="production_board.asp"  >
<span class="icon-coffee"></span><span class="menu-text"> Production Board</span>
                                           </a>


                    </li>                                                                     <li class="item21034" >

            <a class="item" href="acceptance_manager.asp"  >
<span class="icon-wrench"></span><span class="menu-text"> Manage All Jobs</span>
                                           </a>

                    </li>
                    
                   <% END IF %>    
                        
                         <% IF (instr(Session("UserTypes"),"3")) THEN %>
            <li class="item122 " >

            <a class="item icon" href="job_manager.asp"  >

                                <span class="icon-clock"></span><span class="menu-text">View My Jobs</span>            </a>


            </li>
                      <% End IF %>    
                  <li class="item3092" >

           <a class="item" href="javascript:void(0);" onClick="MM_openBrWindow('power_washer_calendar.asp','PWCalendar','width=300,height=700')"><span class="icon-table"></span><span class="menu-text"> Preworker Calendar</a></span>

                    </li>
                    <li class="item3093" >

           <a class="item" href="javascript:void(0);" onClick="MM_openBrWindow('paint_crew_calendar.asp','JCCalendar','width=300,height=700')"><span class="icon-calendar"></span><span class="menu-text"> Job Crew Calendar</a></span>


                    </li>
                    <li class="item4096" >

            <a class="item" href="index_complaints.asp"  >
<span class="icon-lemon"></span><span class="menu-text"> Complaints</span>
                                           </a>



                    </li>
                     <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"7")) THEN %>
                    <li class="item4097" >

            <a class="item" href="jobs_to_invoice.asp"  >
<span class="icon-tasks"></span><span class="menu-text"> Invoice</span>
                                           </a>


                    </li>
                     <li class="item4098" >

            <a class="item" href="payouts.asp"  >
<span class="icon-bell-alt"></span><span class="menu-text"> Payouts</span>
                                           </a>


                    </li>
                    <% END IF %>                                                                               </ul>
                        </div>
                                            </div>

                    </li>
            <%
			END IF
			%>
             <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"7")) THEN %>
                     
              <li class="item118 " >

            <a class="item icon" href="javascript:void(0);"  >

                                <span class="icon-bar-chart"></span><span class="menu-text">Reports</span>            </a>

 <div class="dropdown columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l2">
                                     <li class="item3090" >

            <a class="item" href="index_leads.asp"  >
<span class="icon-lightning"></span><span class="menu-text"> Leads Board</span>
                                           </a>


                    </li> <li class="item3090432" > <a class="item" href="profit_by_estimator.asp"  > <span class="icon-trophy"></span><span class="menu-text"> Profit Board</span></a></li>  
                                      <li class="item803090 parent">
                                      <a class="item" href="javascript:void(0);"  >
<span class="icon-paper-clip"></span><span class="menu-text"> Sales</span>
                                           </a>
                                        <div class="dropdown flyout columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l3">
                                                                                                                
                    <li class="item3091" >

            <a class="item" href="index_sales.asp"  >
<span class="icon-inbox"></span><span class="menu-text"> Weekly Sales</span>
                                           </a>


                    </li>
                    <li class="item3092" >

            <a class="item" href="index_yoy.asp"  >
<span class="icon-repeat"></span><span class="menu-text"> Year Over Year</span>
                                           </a>


                    </li>
                    
                     <li class="item223092" >

            <a class="item" href="rev_month.asp"  >
<span class="icon-calendar"></span><span class="menu-text"> Revenue/Month</span>
                                           </a>


                    </li>
                    
                     <li class="item333092" >

            <a class="item" href="rev_job.asp"  >
<span class="icon-wrench"></span><span class="menu-text"> Revenue/Job</span>
                                           </a>


                    </li>
                    <li class="item343092" >
            <a class="item" href="rev_estimator.asp"  >
<span class="icon-chart"></span><span class="menu-text"> Revenue/Est</span>
                                           </a>
                    </li>                     <li class="item353092" >
            <a class="item" href="rev_crew.asp"  >
<span class="icon-user"></span><span class="menu-text"> Revenue/Crew</span>
                                           </a>
                    </li>
                     <li class="item333092" >
            <a class="item" href="chart4.asp"  >
<span class="icon-cancel"></span><span class="menu-text"> Rejections</span>
                                           </a>
                    </li>      
                                                                              </ul>
                        </div>
                                            </div>

                                      </li>
                                      <li class="item12349 parent" >

            <a class="item" href="javascript:void(0);"  >

                                <span class="icon-paste"></span><span class="menu-text"> Production</span>            </a>
                                           <div class="dropdown flyout columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l3">
                                                                                                                
                    <li class="item143091" >
            <a class="item" href="index_clients.asp"  >
<span class="icon-inbox"></span><span class="menu-text"> Active Customers</span>
            </a>
                    </li>
                    
                     <li class="item153091" >
            <a class="item" href="customer_satisfaction.asp"  >
<span class="icon-thumbs-up"></span><span class="menu-text"> Customer Sat</span>
            </a>
                    </li>
                    
                     <li class="item163091" >
            <a class="item" href="Weekly_Profit.asp"  >
<span class="icon-cog"></span><span class="menu-text"> Foreman Weekly</span>
            </a>
                    </li>
                    
                     <li class="item173091" >
            <a class="item" href="Weekly_WageHours.asp"  >
<span class="icon-money"></span><span class="menu-text"> Wages Weekly</span>
            </a>
                    </li>
                                </ul>
                                </li>
                                                                                
                    <li class="item3093 parent" >

            <a class="item" href="javascript:void(0);"  >
<span class="icon-plus"></span><span class="menu-text"> Profit</span>
                                           </a>
  <div class="dropdown flyout columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l3">
                                                                                                             
                   <li class="item4423092" >

            <a class="item" href="profit_month.asp"  >
<span class="icon-calendar"></span><span class="menu-text"> Profit/Month</span>
                                           </a>


                    </li>
                    
                     <li class="item4433092" >

            <a class="item" href="profit_job.asp"  >
<span class="icon-wrench"></span><span class="menu-text"> Profit/Job</span>
                                           </a>


                    </li>
                    <li class="item4443092" >
            <a class="item" href="profit_estimator.asp"  >
<span class="icon-chart"></span><span class="menu-text"> Profit/Est</span>
                                           </a>
                    </li>                    
                     <li class="item44334092" >
            <a class="item" href="marketing_breakdown.asp"  >
<span class="icon-bullhorn"></span><span class="menu-text"> Marketing ROI</span>
                                           </a>
                    </li>   
</ul>
                    </li>
                    </ul></div></div>
                    
            </li>
            <% END IF %>
            
            
            
            
            
             <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"7")) OR (instr(Session("UserTypes"),"8")) THEN %>
                    
                   
          
 <div class="dropdown columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l2">
                                                                                                                    
                    

            <a class="item" href="index_clients.asp"  >
<span class="icon-group"></span><span class="menu-text"> Active Customers</span>
                                           </a>


                    </li>
                    
                      <li class="item4095" >

            <a class="item" href="customer_satisfaction.asp"  >
<span class="icon-check"></span><span class="menu-text"> Customer Sat</span>
                                           </a>


                    </li>
                     
                    </ul></div></div>
                    
                    

            </li>
            <%
			END IF
			%>
                   
                   
                   
                   
                   <%if session("InternalMessagingYesNo") = True then%>
                <li class="item120"  >

            <a class="item icon" href="javascript:void(0);"  >

                                <span class="icon-comments"></span><span class="menu-text">Messages</span>            </a>

<div class="dropdown columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l2">
                <%
		  'get counts

					  	flash = "false"
			set inbox = oCon.execute("SELECT count(*) as inboxcount FROM EmployeeMessages WHERE clientid = "&Session("clientid")&" and recipientid = "& Session("UserID") &" and Archived=0 ")
			inboxcount = inbox("inboxcount")
			inbox.close
			if inboxcount = 0 then
				set inbox = oCon.execute("SELECT count(*) as inboxcount FROM EmployeeMessages WHERE clientid = "&Session("clientid")&" and recipientid = "& Session("UserID") &" and Archived=0 and mustreply=1 and (messagestatus = 'Read' OR messagestatus = 'Unread') ")
				inboxcount = inbox("inboxcount")
				if cint(inboxcount) > 0 then
					flash = "true"
				end if
				inbox.close
			end if
			set inbox = oCon.execute("SELECT count(*) as inboxcount FROM EmployeeMessages WHERE clientid = "&Session("clientid")&" and recipientid = "& Session("UserID") &" and Archived=0 and mustreply=1 and (messagestatus = 'Read' OR messagestatus = 'Unread') ")
				rinboxcount = inbox("inboxcount")
				if cint(rinboxcount) > 0 then
					flash = "true"
				end if
				inbox.close	
			'if flash = "false"
				set inbox = oCon.execute("SELECT count(*) as inboxcount FROM EmployeeMessages WHERE clientid = "&Session("clientid")&" and recipientid = "& Session("UserID") &" and messagestatus = 'Unread' ")
				rinboxcount = inbox("inboxcount")
				if cint(rinboxcount) > 0 then
					flash = "true"
				end if
				inbox.close		
			'end if
			set inbox = nothing
			set sentbox = oCon.execute("SELECT count(*) as sentboxcount FROM EmployeeMessages WHERE clientid = "&Session("clientid")&" and Archived=0 and senderid = "& Session("UserID") &" ")
			sentboxcount = sentbox("sentboxcount")
			sentbox.close
			set sentbox = nothing
			oCon.execute("update employeemessages set Archived=1 WHERE (((employeemessages.[senderid])="& Session("UserID") &") AND ((employeemessages.[messagestatus])='Read' Or (employeemessages.[messagestatus])='Replied') AND ((DateDiff(DAY, messagedate, GETDATE())>10 )))") 
			
			if flash = "true" then
				%>
                <li class="item4090" >

            <a id="flashtext" class="item" href="user_message.asp"  >
<span class="icon-th-list"></span><span class="menu-text"> Open Messages&nbsp;(<%=inboxcount%>)</span>
                                           </a>


                    </li>
				
				<%
			else
				%>
                  <li class="item4090" >

            <a class="item" href="user_message.asp"  >
<span class="icon-th-list"></span><span class="menu-text"> Open Messages&nbsp;(<%=inboxcount%>)</span>
                                           </a>


                    </li>
               
				<%	
			end if
		  %>
          
            <li class="item4100" >

            <a class="item" href="sent_message.asp"  >
<span class="icon-arrow-up"></span><span class="menu-text"> Sent Messages&nbsp;(<%=sentboxcount%>)</span>
                                           </a>

                    </li>
          
          <li class="item41300" >

            <a class="item" href="user_message_archived.asp"  >
<span class="icon-minus-sign"></span><span class="menu-text"> Archived Messages</span>
                                           </a>

                    </li>
          	<li class="item4100" >

            <a class="item" href="send_message.asp"  >
<span class="icon-envelope-alt"></span><span class="menu-text"> Send New Message</span>
                                           </a>

                </li>   </ul>
                        </div>
                                            </div>
            </li>
           
    <%end if%>        
                   
                   
                   
                   
                   
                   
                   
                   
          <% IF (instr(Session("UserTypes"),"1")) OR (instr(Session("UserTypes"),"7")) THEN %>         
                              
                    <li class="item121" >

            <a class="item icon" href="javascript:void(0);"  >

                                <span class="icon-cogs"></span><span class="menu-text">Settings</span>            </a>

 <div class="dropdown columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="5l2">
                                                                                                                    <li class="item5090" >

            <a class="item" href="global_configuration.asp"  >
<span class="icon-globe"></span><span class="menu-text"> Main Settings</span>
                                           </a>


                    </li>
                     <li class="item5491" >

            <a class="item" href="emailmsg_manage.asp"  >
<span class="icon-envelope-alt"></span><span class="menu-text"> Customer Emails</span>
                                           </a>
                    </li>
                    
                     <li class="item773093 parent" >

            <a class="item" href="javascript:void(0);"  >
<span class="icon-plus"></span><span class="menu-text"> User Settings</span>
                                           </a>
  <div class="dropdown flyout columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l3">
                    
                    <li class="item5091" >

            <a class="item" href="user_manager.asp"  >
<span class="icon-group"></span><span class="menu-text"> User Manager</span>
                                           </a>
                    </li>
                    <li class="item5991" >

            <a class="item" href="estimator_order.asp"  >
<span class="icon-sort"></span><span class="menu-text"> Estimator Order</span>
                                           </a>
                    </li>
                    <li class="item5891" >

            <a class="item" href="message_manager.asp"  >
<span class="icon-comment"></span><span class="menu-text"> Message Manager</span>
                                           </a>
                    </li>
                    </ul></div></div>
                    <li class="item883093 parent" >

            <a class="item" href="javascript:void(0);"  >
<span class="icon-plus"></span><span class="menu-text"> Job Settings</span>
                                           </a>
  <div class="dropdown flyout columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l3">
                    <li class="item5191" >

            <a class="item" href="estimate_types_manager.asp"  >
<span class="icon-briefcase"></span><span class="menu-text"> Job Types</span>
                                           </a>
                    </li>
                   <li class="item5591" >

            <a class="item" href="cancellation_reason_manager.asp"  >
<span class="icon-cancel"></span><span class="menu-text"> Est Cancel Types</span>
                                           </a>
                    </li><li class="item5691" >

            <a class="item" href="job_cancellation_reason_manager.asp"  >
<span class="icon-thumbs-down"></span><span class="menu-text"> Job Cancel Types</span>
                                           </a>
                    </li>
                    
                    <li class="item5391" >

            <a class="item" href="dead_reasons_manager.asp"  >
<span class="icon-minus"></span><span class="menu-text"> Rejection Types</span>
                                           </a>
                    </li><li class="item5791" >

            <a class="item" href="complaint_manager.asp"  >
<span class="icon-lemon"></span><span class="menu-text"> Problem Types</span></a></li>
                    <%if session("DetailedMaterialsYesNo") = True then%>
                    <li class="item3215791" > <a class="item" href="material_category_manager.asp"  > <span class="icon-tag"></span><span class="menu-text"> Manage Materials</span></a></li>
                    <% end if %>
                    </ul></div></div>
                     <li class="item993093 parent" >

            <a class="item" href="javascript:void(0);"  >
<span class="icon-plus"></span><span class="menu-text"> Marketing Settings</span>
                                           </a>
  <div class="dropdown flyout columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l3">
                    <li class="item5291" >

            <a class="item" href="referral_types_manager.asp"  >
<span class="icon-bullhorn"></span><span class="menu-text"> Referral Types</span>
                                           </a>
                    </li><li class="item5391" >

            <a class="item" href="referral_spend_manager.asp"  >
<span class="icon-list"></span><span class="menu-text"> Marketing Costs</span>
                                           </a>
                    </li>
                    </ul></div></div>
                     <li class="item9883093 parent" >

            <a class="item" href="javascript:void(0);"  >
<span class="icon-plus"></span><span class="menu-text"> Data Export</span>
                                           </a>
  <div class="dropdown flyout columns-1 " style="width:180px;">
                                                <div class="column col1"  style="width:180px;">
                            <ul class="l3">
                    <li class="item1100" >

            <a class="item" href="customers_export.asp"  >
<span class="icon-cloud-download"></span><span class="menu-text"> Export Customers</span>
                                           </a>

                    </li>       
                                    
                              <li class="item12100" >

            <a class="item" href="jobs_export.asp"  >
<span class="icon-cloud-download"></span><span class="menu-text"> Export Jobs</span>
                                           </a>

                    </li>
                                     
                    </ul></div></div>
                    </ul></div></div>
                    </li>
                 <% END IF %>   
                    
                 
                      
                       <% IF checkIT2(Session("UserTypes"),"2","7") or checkIT2(Session("UserTypes"),"3","7") or checkIT2(Session("UserTypes"),"4","7") or checkIT2(Session("UserTypes"),"5","7") or checkIT2(Session("UserTypes"),"6","7") or checkIT2(Session("UserTypes"),"8","7") THEN %>
           
            <li class="item1223 " >

            <a class="item icon" href="my_profile.asp"  >

                                <span class="icon-pencil"></span><span class="menu-text">My Profile</span>            </a>


            </li>
            <%
			END IF
			%>
                   
                   
            <li class="item124" >

            <a class="item icon" href="login_redirect.asp"  >

                                <span class="icon-signout"></span><span class="menu-text">Logout</span>            </a>


            </li>
            
            </ul>		<div class="clear"></div>
	
	
</div>
					<div class="clear"></div>
				</div>
			</div>
					</header>
						<div id="rt-transition">
			<div id="rt-mainbody-surround">
																												<div class="rt-container">
					          
<div id="rt-main" class="mb12">
                <div class="rt-container">
                    <div class="rt-grid-12 ">
                                                					

<div id="rt-mainbody">
      <h2>Locate an Existing Customer</h2>
      <form id="CustomerSearch" name="CustomerSearch" method="post" action="customer_results.asp">
        <h2>&nbsp;</h2>
        <table width="60%" border="0">
          <tr>
            <td><h4>Phone Number </h4></td>
            <td><input type="text" name="PhoneNumber" id="PhoneNumber" />
            </td>
          </tr>
          <tr>
            <td><h4>Name</h4></td>
            <td><input type="text" name="CustomerName" id="CustomerName" />
           </td>
          </tr>
          <tr>
            <td><h4>Street</h4></td>
            <td><input type="text" name="Street" id="Street" /></td>
          </tr>
          <tr>
            <td><h4>Comments</h4></td>
            <td><input type="text" name="Comments" id="Comments" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Search" id="Search" value="Search" class="button" /></td>
          </tr>
        </table>
        <table cellpadding="2" cellspacing="0" border="0">
          <tr>
            <td align="center"><input type="hidden" name="WADbSearch1" value="Submit" /></td>
          </tr>
        </table>
      </form>
      <p>&nbsp;</p>
      <h1><br />
      </h1>
<div class="clear"></div>

	</div>

    <br class="clearFloat" />
                                                                    </div>
                                        <div class="clear"></div>
                </div>
            </div>
				</div>
															</div>
		</div>
						<footer id="rt-footer-surround">
						<div id="rt-footer">
				<div class="rt-container">
					<div class="rt-grid-8 rt-alpha">
               <div class="rt-block box5 fp-footer-a">
           	<div class="module-surround">
	           		                	<div class="module-content">
	                		

<div class="custombox5 fp-footer-a"  >
	<div class="rt-footer-logo" style="height:35px;" > 
	</div>
</div>
	                	</div>
                	</div>
           </div>
	
</div>
<div class="rt-grid-4 rt-omega">
               <div class="rt-block fp-footer-b">
           	<div class="module-surround">
	           		                	<div class="module-content">
	                		

<div class="custombox5 fp-footer-b"  >
	<br>
<a href="javascript:void(0);" ><i class="icon-question-sign icon-help-huge" onClick="MM_openBrWindow('/instructions/homepage.html','homepage','scrollbars=yes,resizable=yes,width=600,height=400')"></i></a>



</div>
	                	</div>
                	</div>
           </div>
	
</div>
					<div class="clear"></div>
				</div>
			</div>
									<div id="rt-copyright">
				<div class="rt-container">
					<div class="rt-grid-3 rt-alpha">
    	<div class="clear"></div>
				  </div>
<div class="rt-grid-7">
               <div class="rt-block horizmenu rt-center hidden-phone">
           	<div class="module-surround">
	           		                	<div class="module-content">
	                		<ul class="nav menu">
<li class="item-134"></li></ul>
	                	</div>
               	 </div>
           </div>
	
</div>
<div class="rt-grid-2 rt-omega">
    	<div class="clear"></div>
</div>
					<div class="clear"></div>
				</div>
				
                          </div>
					</footer>
									</div>
</body>
</html>
<%
User.Close()
Set User = Nothing
%>
<%
summary.Close()
Set summary = Nothing
%>

Open in new window


 The mande2 connection file is used on all other pages and works great.

The authentication check also appears on every other page of the site, and doesn't kick us on other pages.

Any suggestions would be great. I'm OK with chasing down error messages, but inexplicable session state behavior is pretty confounding.

Thanks

Bill
0
Comment
Question by:billium99
  • 11
  • 8
20 Comments
 
LVL 5

Expert Comment

by:R. Toby Richards
Comment Utility
You'll probably be better off asking this question in Programming / ASP or Programming / MS Development.
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
Hmm - except that I know the ASP application code talks to the database correctly in previous versions of Windows Server, and is generally connecting and talking normally on other pages. I guess I can re-submit...
0
 
LVL 5

Expert Comment

by:R. Toby Richards
Comment Utility
If you really think it is an IIS issue, then maybe submit the portion of the IIS log that describes the error?
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
I'm not sure if it's IIS - I just know it's unlikely to be the ASP code itself, as it worked great on the previous server. I'm leaning toward MS SQL. One thing that could be relevant: I recovered this database using the Management Console and attaching the MDF file from a crashed server.

How can I tell if all my tables are intact? I have a couple of TSQL commands I've found, but honestly I can't figure out how to launch MS SQL command line in Server 2012.

I've attached a MS SQL error log that shows the restarts and mentions something about:

SPN failed to start and:

"Failure to register an SPN may cause integrated authentication to fall back to NTLM instead of Kerberos"

Would this be related? I mean, again, I can connect to the database, read data from it - all with no issues. But certain pages which may be trying to write to the database (that may be the difference) are when we get thrown back to the login page.

Any suggestion is much appreciated.

Bill
ERRORLOG.zip
0
 
LVL 5

Expert Comment

by:R. Toby Richards
Comment Utility
Use the MSSQL Management Console to run some maintenance tasks on the database. DBCC CHECKDB may be helpful:

https://msdn.microsoft.com/en-us/library/ms176064.aspx
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
Thanks Toby - well I'm happy, yet flummoxed to report:

CHECKDB found 0 allocation errors and 0 consistency errors in database 'simplesource_live'.

So the database structure itself is not causing the issues...
0
 
LVL 5

Expert Comment

by:R. Toby Richards
Comment Utility
It looks like the SPN error might have something to do with it. This page looks promising:

http://blogs.technet.com/b/mdegre/archive/2009/11/20/the-sql-network-interface-library-was-unable-to-register-spn.aspx
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
So mine was 0x54b - which just translated to ERROR_NO_SUCH_DOMAIN

So maybe we're zeroing in here...

On the old server, we were using SSL when the server froze and went down.

On the new server, we have not deployed SSL. Would that cause the issue? To what DOMAIN value is the error referring?
0
 
LVL 5

Expert Comment

by:R. Toby Richards
Comment Utility
Whatever domain the previous database server was on. SSL may cause the problem, but it sounds like the database had hooks into a different domain. I don't know how complex the program is, but have you considered porting it, and migrating the data to MySQL? You wouldn't have these problems with MySQL. MSSQL is notorious for getting wonky like this when you move data files to different hardware.
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
It's pretty complex - and it's been down for 8 days and I'm staring at a working version, with all data intact, but with this one confounding problem preventing any usage of the app.

I've considered MySQL - at the time we migrated to MS SQL, we were coming from an Access database, and MS SQL seemed like a better route.

In any case, I'm going to shoot for deploying the SSL certificate tomorrow and see what difference that might make.

Thanks for your time. I may have more clarifying questions soon...

Bill
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 1

Author Comment

by:billium99
Comment Utility
Unfortunately this was not the problem. I'm also not seeing any other meaningful error in the SQL logs. I suppose this could be some kind of ASP session state issue, although it's not happening on all pages which connect to the database; only certain ones. And while I was thinking it's only happening on pages which INSERT and/or UPDATE records, it's occurring right at page load, as a simple page refresh after page load throws me back to the login screen, so I'm not sure how much difference the page functions should really make. Or it's something unique to these pages outside of the record handling...

Bill
0
 
LVL 5

Accepted Solution

by:
R. Toby Richards earned 500 total points
Comment Utility
Have you tried troubleshooting with Fiddler? It's an awesome utility that will show all the activity of your web browser. It may show your web browser receiving some interesting HTML codes when the page in question fails.
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
Thanks Toby - I have Fiddler installed - I've run the SSL configuration so I can see the traffic, and I can see events streaming down the page when I'm getting booted back to the login page.

But what exactly would I be looking for here? Under which tab would you start? I see a 302 event - presumably that is the moment where we are redirected. But I'm not sure in what section to review log data (which tab) to isolate a description of what is happening.

I do see one error - a 404 takes place during page load on a loader.white.gif but I'm not sure how to proceed.

I'm going to remove the request for that gif file and see what happens, but this page has been like this, with the erroneous file, for some time now...
0
 
LVL 5

Expert Comment

by:R. Toby Richards
Comment Utility
302 is in fact a redirect. It is also an HTML header. Somewhere in the ASP code is a deliberate 302 header. Find it in the ASP code, and maybe you can see why the app is choosing to do a redirect.
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
Well the app checks for an authenticated session ID, and redirects to the login page if the authentication fails, but that's true of every page of the application, once logged in...

I'll look more closely.

Bill
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
Hmm - so new development:

If I strip out the authentication check, I can now refresh on the page that was booting me, however if I try to do a record UPDATE on that page, it chooses to boot me then.

However, the UPDATE works with authentication check removed. Once I log back in, I see that my change was successfully saved. I also just realized that I pasted the wrong ASP code in my original question. I understand if you aren't crazy about sorting through thousands of lines of code. I believe all the authentication and record UPDATE code is in what I pasted. I left out the HTML body and subsequent code, but I did leave in a few irrelevent (?) record sets to preserve that email code in case it's related:

<%@LANGUAGE="VBSCRIPT"%>
<%
' functions are typically at the top or bottom of your page.
function checkIT(user_type,valueToCheckInclude, valueToCheckExclude)
     checkInclude=false
     checkExclude=true
     arrUsertype=split(user_type,",")
     for each number in arrUsertype
          if cstr(number)=cstr(valueToCheckInclude) then
               checkInclude=true
         end if
         if cstr(number)=cstr(valueToCheckExclude) then
               checkExclude=false
         end if

    next
    if checkInclude = true And checkExclude = true then
     checkIT = true
   else
     checkIT = false
   End if
end function

function checkIT2(user_type2,valueToCheckInclude2, valueToCheckExclude2)
user_type2=replace(user_type2," ","")
	if instr(","& user_type2 &",",","& valueToCheckInclude2 &",")>0 AND instr(","& user_type2 &",",","& valueToCheckExclude2 &",")=0 then
		checkIT2=True
	else
		checkIT2=False
	end if
end function
%>
<!--#include file="sendMail.asp" -->
<!--#include file="Connections/mande2.asp" -->
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="login_redirect.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>



<%
set oCon = server.CreateObject("ADODB.Connection")
oCon.open MM_mande_STRING

Dim Master__MMColParam
Master__MMColParam = "1"
If (Request.QueryString("JobID") <> "") Then 
  Master__MMColParam = Request.QueryString("JobID")
End If
%>
<%
Dim Master
Dim Master_cmd
Dim Master_numRows

Set Master_cmd = Server.CreateObject ("ADODB.Command")
Master_cmd.ActiveConnection = MM_mande_STRING
Master_cmd.CommandText = "SELECT *, Customers.CustomerID as CustomerID, Customers.CustomerFirstName, Customers.CustomerLastName, Customers.BusinessName, Customers.CustomerPhoneHome, Customers.CustomerPhoneCell , Customers.CustomerWorkPhone, Customers.CustomerEmail, Users.UserID, Users.UserFirstName, Users.UserLastName,Users.UserEmail,Users.UserPhone1 FROM Jobs, Customers, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? AND Customers.CustomerID=Jobs.CustomerID AND Users.UserID=Jobs.EstimatorAssigned" 
Master_cmd.Prepared = true
Master_cmd.Parameters.Append Master_cmd.CreateParameter("param1", 5, 1, -1, Master__MMColParam) ' adDouble

Set Master = Master_cmd.Execute

sCustomerFName = Master.Fields.Item("CustomerFirstName").Value
CustomerEmail = Master.Fields.Item("CustomerEmail").Value
if CustomerEmail = "" then
	CustomerEmail = "111"
end if
sEstStatus = Master.Fields.Item("EstimateStatus").Value
userfname = Master.Fields.Item("UserFirstName").Value
userlname = Master.Fields.Item("UserLastName").Value
useremail = Master.Fields.Item("UserEmail").Value
userphone = Master.Fields.Item("UserPhone1").Value
body_email = "xxx"

surveylink = " <a href =www.simplesourcecrm.com/survey0.asp?email="&useremail&"?JobID="&Master__MMColParam&">Click here</a> "
			
			Set Master_cmd = Server.CreateObject ("ADODB.Command")
		Master_cmd.ActiveConnection = MM_mande_STRING
		Master_cmd.CommandText = "SELECT *, Customers.CustomerID, Customers.CustomerFirstName, Customers.CustomerLastName, Customers.BusinessName, Customers.CustomerPhoneHome, Customers.CustomerPhoneCell , Customers.CustomerWorkPhone, Customers.CustomerEmail, users.UserImage,Users.UserID, Users.UserFirstName, Users.UserLastName,Users.UserEmail,Users.UserPhone1 FROM Jobs, Customers, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? AND Customers.CustomerID=Jobs.CustomerID AND Users.UserID=Jobs.CreatedByUserID" 
		Master_cmd.Prepared = true
		Master_cmd.Parameters.Append Master_cmd.CreateParameter("param1", 5, 1, -1, request("jobid")) ' adDouble
		
		Set Master1 = Master_cmd.Execute
		
		UserImageoff = Master1.Fields.Item("UserImage").Value
		offuserfname = Master1.Fields.Item("UserFirstName").Value
		
		Set Master_cmd = Server.CreateObject ("ADODB.Command")
		Master_cmd.ActiveConnection = MM_mande_STRING
		Master_cmd.CommandText = "SELECT *, Customers.CustomerID, Customers.CustomerFirstName, Customers.CustomerLastName, Customers.BusinessName, Customers.CustomerPhoneHome, Customers.CustomerPhoneCell , Customers.CustomerWorkPhone, Customers.CustomerEmail, users.UserImage,Users.UserID, Users.UserFirstName, Users.UserLastName,Users.UserEmail,Users.UserPhone1 FROM Jobs, Customers, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? AND Customers.CustomerID=Jobs.CustomerID AND Users.UserID=Jobs.EstimatorAssigned" 
		Master_cmd.Prepared = true
		Master_cmd.Parameters.Append Master_cmd.CreateParameter("param1", 5, 1, -1, request("jobid")) ' adDouble
		
		Set Master1 = Master_cmd.Execute
		
		UserImageest = Master1.Fields.Item("UserImage").Value
		estuserfname = Master1.Fields.Item("UserFirstName").Value
		
		Set Master_cmd = Server.CreateObject ("ADODB.Command")
		Master_cmd.ActiveConnection = MM_mande_STRING
		Master_cmd.CommandText = "SELECT *, Customers.CustomerID, Customers.CustomerFirstName, Customers.CustomerLastName, Customers.BusinessName, Customers.CustomerPhoneHome, Customers.CustomerPhoneCell , Customers.CustomerWorkPhone, Customers.CustomerEmail, users.UserImage,Users.UserID, Users.UserFirstName, Users.UserLastName,Users.UserEmail,Users.UserPhone1 FROM Jobs, Customers, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? AND Customers.CustomerID=Jobs.CustomerID AND Users.UserID=Jobs.JobManagerAssigned" 
		Master_cmd.Prepared = true
		Master_cmd.Parameters.Append Master_cmd.CreateParameter("param1", 5, 1, -1, request("jobid")) ' adDouble
		
		Set Master1 = Master_cmd.Execute
		if not Master1.eof then
		UserImageprod = Master1.Fields.Item("UserImage").Value
		produserfname = Master1.Fields.Item("UserFirstName").Value
		produserlname = Master1.Fields.Item("UserLastName").Value
		end if
		''estuserfname = Master1.Fields.Item("UserFirstName").Value

			set oRsEmail = oCon.Execute("SELECT CreatedDefaultMessage,AcceptedDefaultMessage,RejectedDefaultMessage,ClosedDefaultMessage,SimpleCreatedMessage,SimpleEstimatedMessage,SimpleAcceptedMessage,SimpleClosedMessage,SimpleRejectedMessage FROM emailmsgs where clientid = "&Session("clientid"))
			'if session("SimpleOrAdvancedEmail") = True then
			'body_emailarr = split(oRsEmail("CreatedDefaultMessage"),"[@##@]")
			'body_email = "<font face='Arial'><table border=0><tr><td valign=top align=center width=100><img src='http://www."&session("DomainName")&"/uploads/75_"&UserImageest&"'><br>Estimator: "&estuserfname&"</td><td valign=top>" & replace(body_emailarr(0),"[$##$]","") & "</td></tr><tr><td valign=top align=center width=100><img src='http://www."&session("DomainName")&"/uploads/75_"&UserImageoff&"'><br>Office: "&offuserfname&"</td><td valign=top>" & replace(body_emailarr(1),"[$##$]","") & "</td></tr><tr><td colspan=2><br>" & replace(body_emailarr(2),"[$##$]","") & "</td></tr></table></font>"
			
			body_email = "<table border=0><tr><td>"&replace(oRsEmail("CreatedDefaultMessage"),"[+estimatorimage+]","<img src='http://www.simplesourcecrm.com/uploads/75_"&UserImageest&"' align='left'>")&"</td></tr></table>"
			'else
			'body_email = "<table border=0><tr><td>"&replace(oRsEmail("CreatedDefaultMessage"),"[+estimatorimage+]","")&"</td></tr></table>"
			'end if
			if session("SimpleOrAdvancedEmail") = True then
			body_email1 = oRsEmail("AcceptedDefaultMessage")
			
			'body_email1 = replace(body_email1,"~","&")
			'body_emailarr = split(body_email1,"[@##@]")
			'body_email1 = "<font face='Arial'><table border=0><tr><td valign=top align=center width=100><img src=http://www.maxgeekweb1.com/uploads/75_"&UserImageest&"><br><br>Estimator: "&estuserfname&"</td><td valign=top>" & replace(body_emailarr(0),"[$##$]","") & "</td></tr><tr><td valign=top align=center width=100><img src=http://www.maxgeekweb1.com/uploads/75_"&UserImageprod&"><br><br>Job Manager: "&userfname&"</td><td valign=top>" & replace(body_emailarr(1),"[$##$]","") & "</td></tr><tr><td colspan=2><br>" & replace(body_emailarr(2),"[$##$]","") & "</td></tr></table></font>"

			'body_email1a = "<font face='Arial'>Dear [+customername+],<br><br><br>"&vbcrlf&vbcrlf&vbcrlf&"Thank you for choosing M ~ E Painting to be your painter. You will not be disappointed! Thank you for placing your confidence and trust in our company. We promise to deliver an excellent service experience to you before, during, and after your painting project. As always, along with the service experience there will be only experienced craftsmen working on your home. Your estimator [+estimatorfname+] [+estimatorlname+] will be contacting you to talk more about specific dates and times for painting. [+estimatorfname+]'s's cell phone is [+estimatorcell+], and email is  [+estimatoremail+]. If you have any questions with regard to the scheduling please call or email [+estimatorfname+] directly. We are looking forward to serving you on this project. Your complete satisfaction is our ultimate goal! <br><br><br>"&vbcrlf&vbcrlf&vbcrlf&"Sincerely,<br><br>"&vbcrlf&vbcrlf&vbcrlf&"The M ~ E Painting Team<br>www.mandepainting.com<br>(970)-207-1005 office<br>888-7-PAINT-9 toll free<br>(970)-613-0772 fax<br>540 W. 66th St. B1<br>Loveland, CO 80538<br></font>"
			body_email1a = "<table border=0><tr><td>"&replace(oRsEmail("AcceptedDefaultMessage"),"[+prodmanagerimage+]","<img src='http://www.simplesourcecrm.com/uploads/75_"&UserImageprod&"' align='left'>")&"</td></tr></table>"
			else
			body_email1a = "<table border=0><tr><td>"&replace(oRsEmail("AcceptedDefaultMessage"),"[+prodmanagerimage+]","")&"</td></tr></table>"
			end if
			
			'if session("SimpleOrAdvancedEmail") = True then
			body_email2 = "<font face='Arial'>"&oRsEmail("RejectedDefaultMessage")&"</font>"
			'else
			'body_email2 = "<font face='Arial'>"&oRsEmail("SimpleRejectedMessage")&"</font>"
			'end if
			'if session("SimpleOrAdvancedEmail") = True then
			body_email3 = "<font face='Arial'>"&oRsEmail("ClosedDefaultMessage")&"</font>"
			'else
			'body_email3 = "<font face='Arial'>"&oRsEmail("SimpleClosedMessage")&"</font>"
			'end if
			oRsEmail.close
			set oRsEmail = nothing
Dim EstimateDate__MMColParam
EstimateDate__MMColParam = "1"
If (Request.QueryString("JobID") <> "") Then 
  EstimateDate__MMColParam = Request.QueryString("JobID")
End If
%>
<%
Dim EstimateDate
Dim EstimateDate_cmd
Dim EstimateDate_numRows


if (sEstStatus <> "Cancelled") AND (sEstStatus <> "Reschedule") then
	Set EstimateDate_cmd = Server.CreateObject ("ADODB.Command")
	EstimateDate_cmd.ActiveConnection = MM_mande_STRING
	EstimateDate_cmd.CommandText = "SELECT EventStartDate,EventStartTime FROM CalendarEvents WHERE clientid = "&Session("clientid")&" and AssignedJobID = ?" 
	EstimateDate_cmd.Prepared = true
	EstimateDate_cmd.Parameters.Append EstimateDate_cmd.CreateParameter("param1", 5, 1, -1, EstimateDate__MMColParam) ' adDouble
	
	Set EstimateDate = EstimateDate_cmd.Execute
	
	''Set EstimateDate = EstimateDate_cmd.Execute
	if not EstimateDate.eof then
		dSelStartTime = EstimateDate.Fields.Item("EventStartTime").Value
		dSelDate = EstimateDate.Fields.Item("EventStartDate").Value
		if minute(dSelStartTime) = 0 then
			dSelStartTimem = "00"
		else
			dSelStartTimem = minute(dSelStartTime)
		end if
		if cint(hour(dSelStartTime)) > 12 then
			SelStartTime = cint(hour(dSelStartTime))-12 & ":" & dSelStartTimem &  " pm"
		else
			SelStartTime = cint(hour(dSelStartTime)) & ":" & dSelStartTimem &  " am"
		end if
		if cint(hour(dSelStartTime)) = 12 then
			SelStartTime = "12:" & dSelStartTimem &  " pm"
		end if
	end if
	
	EstimateDate_numRows = 0
	

else
	SelStartTime = "00:00"
	dseldate = ""	
end if				
body_email = replace(body_email,"[+customername+]",sCustomerFName)
body_email = replace(body_email,"[+datetime+]",dseldate & " " & selstarttime)
body_email = replace(body_email,"[+officefname+]",offuserfname)
body_email = replace(body_email,"[+estimatorfname+]",userfname)
body_email = replace(body_email,"[+estimatorlname+]",userlname)
body_email = replace(body_email,"[+estimatorcell+]",userphone)
body_email = replace(body_email,"[+estimatoremail+]",useremail)
body_email = replace(body_email,"~","&")


body_email2 = replace(body_email2,"[+customername+]",sCustomerFName)
body_email2 = replace(body_email2,"[+datetime+]",dseldate & " " & selstarttime)
body_email2 = replace(body_email2,"[+estimatorfname+]",userfname)
body_email2 = replace(body_email2,"[+estimatorlname+]",userlname)
body_email2 = replace(body_email2,"[+estimatorcell+]",userphone)
body_email2 = replace(body_email2,"[+estimatoremail+]",useremail)
body_email2 = replace(body_email2,"~","&")

body_email3 = replace(body_email3,"[+customername+]",sCustomerFName)
body_email3 = replace(body_email3,"[+datetime+]",dseldate & " " & selstarttime)
body_email3 = replace(body_email3,"[+estimatorfname+]",userfname)
body_email3 = replace(body_email3,"[+estimatorlname+]",userlname)
body_email3 = replace(body_email3,"[+estimatorcell+]",userphone)
body_email3 = replace(body_email3,"[+estimatoremail+]",useremail)
body_email3 = replace(body_email3,"[+survey+]",surveylink)
body_email3 = replace(body_email3,"~","&")

Master_numRows = 0
%>

<%
Dim User__MMColParam
User__MMColParam = "1"
If (Session("MM_Username") <> "") Then 
  User__MMColParam = Session("MM_Username")
End If
%>
<%
Dim User
Dim User_cmd
Dim User_numRows

Set User_cmd = Server.CreateObject ("ADODB.Command")
User_cmd.ActiveConnection = MM_mande_STRING
User_cmd.CommandText = "SELECT * FROM Users WHERE clientid = "&Session("clientid")&" and UserName = ?" 
User_cmd.Prepared = true
User_cmd.Parameters.Append User_cmd.CreateParameter("param1", 200, 1, 255, User__MMColParam) ' adVarChar

Set User = User_cmd.Execute
User_numRows = 0
%>

<% 
CurrentNotes = (Master.Fields.Item("Comments").Value)
CurrentColorNotes = (Master.Fields.Item("ColorComments").Value) 
%>

<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function
%>

<%
If (CStr(Request("MM_update")) = "MasterEditor") Then
  If (Not MM_abortEdit) Then

	set rs = oCon.execute("select ContactLogID from contactlog where clientid = "&Session("clientid")&" and JobID = "&Request("JobID")&" and LoggedInUserID = "&session("userid")&" and contactnotes like '%"& "changed this Job status to " & Request.Form("EstimateStatus")  &"%'")
	if rs.eof then
		oCon.execute("insert into contactlog (JobID,LoggedInUserID,ContactTypeID,ContactDate,ContactTime,ContactNotes,clientid) values("&Request("JobID")&","&session("userid")&",2,GETDATE(),CONVERT(TIME,GETDATE()),' changed this Job status to " & Request.Form("EstimateStatus") & "',"&session("clientid")&")")
	end if
	set rs = nothing		
    ' execute the update
    Dim MM_editCmd
	Set MM_editCmd = Server.CreateObject ("ADODB.Command")
	if Request.Form("EstimateStatus") = "Cancelled" then
		MM_editCmd.CommandText = "update jobs set AcceptedDate = NULL,AcceptedPrice=NULL WHERE JobID = " & Request("JobID") 
	end if	
	
	if Request.Form("EstimateStatus") = "Cancelled" and Request.Form("EstimatedPrice") = "" then
		
		MM_editCmd.ActiveConnection = MM_mande_STRING
		MM_editCmd.CommandText = "update jobs set ReasonWhyCancelled="&request("CancelReason")&"  WHERE JobID = " & Request("JobID") 
		MM_editCmd.Execute
		oCon.execute("delete from calendarevents WHERE clientid = "&Session("clientid")&" and AssignedJobID = " & Request("JobID") )
	end if
	
	if (Request.Form("EstimateStatus") = "Cancelled" and Request.Form("EstimatedPrice") <> "")  then
		cancelleddate = request("cancelleddate")
		if request("cancelleddate") = "" then
			cancelleddate = now()
		end if
		sendNotification Request("JobID"), 99999999, Request.Form("EstimatorAssigned"), ""
		Set MM_editCmd = Server.CreateObject ("ADODB.Command")
		MM_editCmd.ActiveConnection = MM_mande_STRING
		MM_editCmd.CommandText = "delete from calendarevents WHERE clientid = "&Session("clientid")&" and AssignedJobID = " & Request("JobID") 
		MM_editCmd.Execute
		'MM_editCmd.ActiveConnection.Close
		Set MM_editCmd = Server.CreateObject ("ADODB.Command")
		MM_editCmd.ActiveConnection = MM_mande_STRING
		accpr = Request.Form("AcceptedPrice")
		if accpr = "" then
			accpr = 0
		else
			accpr = Request.Form("AcceptedPrice")	
		end if
		if request("CancelReason") = "" then
			
			MM_editCmd.CommandText = "update jobs set AcceptedDate = NULL,AcceptedPrice=NULL,ReasonWhyJobCancelled="&request("jobCancelReason")&",CancelledAmount="&accpr&",CancelledDate = '"&cancelleddate&"' WHERE JobID = " & Request("JobID") 
		else

			MM_editCmd.CommandText = "update jobs set AcceptedDate = NULL,AcceptedPrice=NULL,ReasonWhyCancelled="&request("CancelReason")&",CancelledAmount="&accpr&",CancelledDate = '"&cancelleddate&"' WHERE JobID = " & Request("JobID") 
		end if		
		MM_editCmd.Execute
		'MM_editCmd.ActiveConnection.Close
	end if
	if Request.Form("EstimateStatus") = "Reschedule" then
	
	end if
	if Request.Form("EstimateStatus") = "Rejected" then
		Set MM_editCmd = Server.CreateObject ("ADODB.Command")
		MM_editCmd.ActiveConnection = MM_mande_STRING
		MM_editCmd.CommandText = "update jobs set AcceptedDate = NULL,AcceptedPrice=NULL WHERE JobID = " & Request("JobID") 
		MM_editCmd.Execute
		'MM_editCmd.ActiveConnection.Close
	end if
	if Request.Form("EstimateStatus") = "Completed" then
		oCon.Execute("update jobs set PaintEndDate = '"&request("PaintEndDate") &"' where JobID = " & Request("JobID"))
		if Request.Form("FinalPaymentStatus") = "Paid" then
		
			set rsa = oCon.execute("select ActualJobCompletion from jobs where clientid = "&Session("clientid")&" and JobID = " & Request("JobID"))
		
			Set MM_editCmd = Server.CreateObject ("ADODB.Command")
			MM_editCmd.ActiveConnection = MM_mande_STRING
			MM_editCmd.CommandText = "update jobs set ActualJobCompletion = '"&request("ActualJobCompletion")&"' where JobID = " & Request("JobID") 
			MM_editCmd.Execute
		
		end if	
		set rsa = nothing
	end if

	accdate = Request.Form("AcceptedDate")
	accdateold = Request.Form("AcceptedDateold")
	

	if accdate = "" then
		accdate = ""
	else	
		accdate = month(accdate)&"/"& day(accdate)& "/"&year(accdate) & " " & time()
	end if
	'if accdate <> "" then	
	'	if month(accdateold)&"/"& day(accdateold)& "/"&year(accdateold) <> month(accdate)&"/"& day(accdate)& "/"&year(accdate) then
	'	accdate = month(accdate)&"/"& day(accdate)& "/"&year(accdate) & " " & time()
	'	end if
	'end if

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_mande_STRING
	if session("YearBuiltYesNo") = True then
		sql= "UPDATE Jobs SET yearbuilt = ?,JobAddress1 = ?, JobAddress2 = ?, JobCity = ?, JobState = ?, JobZipCode = ?, EstimatedPrice = ?, JobSubDivision = ?, AcceptedPrice = ?,AcceptedDate = ?,DesiredStartDate = ?,DesiredStartWeek = ?,ReasonWhyNo = ?,EstimatorAssigned=?, EstimateType = ?, HoursBudgeted = ?, ReferralType = ?,  Comments = ?, HoursSpent = ?, ColorComments = ?, EstimateStatus = ?, FinalPaymentType = ?, FinalPaymentStatus = ?, FinalPriceBilled = ?,EstimatedMaterialsCost=?,EstimatedLaborCost=?,JobLaborCost=?,JobMaterialsCost=?,[Deposit Amount] = ?,PowerWasherCost=?,JobManagerAssigned=?,PaintStartDate=?,PaintEndDate=?,CrewForeman=? WHERE JobID = ?" 
	else
		sql="UPDATE Jobs SET JobAddress1 = ?, JobAddress2 = ?, JobCity = ?, JobState = ?, JobZipCode = ?, EstimatedPrice = ?, JobSubDivision = ?, AcceptedPrice = ?,AcceptedDate = ?,DesiredStartDate = ?,DesiredStartWeek = ?,ReasonWhyNo = ?,EstimatorAssigned=?, EstimateType = ?, HoursBudgeted = ?, ReferralType = ?,  Comments = ?, HoursSpent = ?, ColorComments = ?, EstimateStatus = ?, FinalPaymentType = ?, FinalPaymentStatus = ?, FinalPriceBilled = ?,EstimatedMaterialsCost=?,EstimatedLaborCost=?,JobLaborCost=?,JobMaterialsCost=?,[Deposit Amount] = ?,PowerWasherCost=?,JobManagerAssigned=?,PaintStartDate=?,PaintEndDate=?,CrewForeman=? WHERE JobID = ?" 
	end if	
    MM_editCmd.CommandText = sql
    MM_editCmd.Prepared = true
	if session("YearBuiltYesNo") = True then
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param61", 5, 1, -1, MM_IIF(Request.Form("yearbuilt"), Request.Form("yearbuilt"), null)) ' adDouble
	end if
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 150, Request.Form("Address1")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 150, Request.Form("Address2")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 150, Request.Form("City")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 150, Request.Form("State")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 50, Request.Form("Zip")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 5, 1, -1, MM_IIF(Request.Form("EstimatedPrice"), Request.Form("EstimatedPrice"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 5, 1, -1, MM_IIF(Request.Form("JobSubDivision"), Request.Form("JobSubDivision"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 5, 1, -1, MM_IIF(Request.Form("AcceptedPrice"), Request.Form("AcceptedPrice"), null)) ' adDouble
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param28", 135, 1, -1, MM_IIF(accdate,accdate,null)) ' adDate
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param29", 7, 1, 10, MM_IIF(Request.Form("DesiredStartDate"),Request.Form("DesiredStartDate"),null)) ' adDate
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param30", 7, 1, 10, MM_IIF(Request.Form("DesiredStartWeek"),Request.Form("DesiredStartWeek"),null)) ' adDate
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param31", 3, 1, 3, MM_IIF(Request.Form("WhyDead"),Request.Form("WhyDead"),null)) ' adInteger
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param32", 3, 1, 3, MM_IIF(Request.Form("EstimatorAssigned"),Request.Form("EstimatorAssigned"),null)) ' adInteger
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 5, 1, -1, MM_IIF(Request.Form("EstimateType"), Request.Form("EstimateType"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 5, 1, -1, MM_IIF(Request.Form("HoursBudgeted"), Request.Form("HoursBudgeted"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 5, 1, -1, MM_IIF(Request.Form("ReferralType"), Request.Form("ReferralType"), null)) ' adDouble
	IF cStr(Request.Form("Comments"))="" THEN
	 MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 203, 1, 1073741823, MM_IIF(CurrentNotes, CurrentNotes, null))
	 ELSE
	 	if request("contacttype2") <> "" then
			contactypetext = split(request("contacttype2"),"*")
			CurrentNotes = CurrentNotes&"<br>"&NOW&" - "&(User.Fields.Item("UserFirstName").Value)&" "&(User.Fields.Item("UserLastName").Value)&" - "&contactypetext(1)&" - "&Request.Form("Comments") 
		end if
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 203, 1, 1073741823,CurrentNotes ) ' adLongVarWChar
	END IF
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 5, 1, -1, MM_IIF(Request.Form("HoursSpent"), Request.Form("HoursSpent"), null)) ' adDouble
	IF cStr(Request.Form("ColorComments"))="" THEN
	 MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 203, 1, 1073741823, MM_IIF(CurrentColorNotes, CurrentColorNotes, null))
	 ELSE
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 203, 1, 1073741823, CurrentColorNotes&"<br>"&(User.Fields.Item("UserFirstName").Value)&" "&(User.Fields.Item("UserLastName").Value)&"- "&NOW&": "&Request.Form("ColorComments")) ' adLongVarWChar
	END IF
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 202, 1, 255, Request.Form("EstimateStatus")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param17", 202, 1, 255, Request.Form("FinalPaymentType")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param18", 202, 1, 255, Request.Form("FinalPaymentStatus")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param19", 5, 1, -1, MM_IIF(Request.Form("FinalPriceBilled"), Request.Form("FinalPriceBilled"), null)) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param21", 5, 1, -1, MM_IIF(Request.Form("EstimatedMaterialsCost"), Request.Form("EstimatedMaterialsCost"), null)) ' adDouble
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param22", 5, 1, -1, MM_IIF(Request.Form("EstimatedLaborCost"), Request.Form("EstimatedLaborCost"), null)) ' adDouble

	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param23", 5, 1, -1, MM_IIF(Request.Form("JobLaborCost"), Request.Form("JobLaborCost"), null)) ' adDouble
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param24", 5, 1, -1, MM_IIF(Request.Form("JobMaterialsCost"), Request.Form("JobMaterialsCost"), null)) ' adDouble
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param25", 5, 1, -1, MM_IIF(Request.Form("Deposit Amount"), Request.Form("Deposit Amount"), null)) ' adDouble
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param250", 5, 1, -1, MM_IIF(Request.Form("PowerWasherCost"), Request.Form("PowerWasherCost"), null)) ' adDouble
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param251", 3, 1, 3, MM_IIF(Request.Form("prodmanager"),Request.Form("prodmanager"),0)) ' adInteger
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param29", 7, 1, 10, MM_IIF(Request.Form("PaintStartDate"),Request.Form("PaintStartDate"),null)) ' adDate
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param30", 7, 1, 10, MM_IIF(Request.Form("PaintEndDate"),Request.Form("PaintEndDate"),null)) ' adDate
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param31", 3, 1, 3, MM_IIF(Request.Form("CrewForeman"),Request.Form("CrewForeman"),null)) ' adInteger
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param20", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
    MM_editCmd.Execute
    'MM_editCmd.ActiveConnection.Close
	''update contactlog
	if request("contactlog2") <> "" and request("contacttype2") <> "" then
		contactypetext = split(request("contacttype2"),"*")
		
		oCon.execute("insert into ContactLog (JobID,LoggedInUserID,ContactTypeID,ContactDate,ContactTime,ContactNotes,clientid) values("&Request.Form("MM_recordId")&","&Session("UserID")&","&contactypetext(0)&",GETDATE(),CONVERT(TIME,GETDATE()),'"&replace(request("contactlog2"),"'","''")&"',"&session("clientid")&")")
	end if
    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
	if request("from") <> "" then
    	MM_editRedirectUrl = request("from")& ".asp"
	else	
		MM_editRedirectUrl = "estimate_manager_completed.asp"
	end if
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If

%>



<%
Dim CrewForeman__MMColParam
CrewForeman__MMColParam = "1"
If (Request.QueryString("JobID") <> "") Then 
  CrewForeman__MMColParam = Request.QueryString("JobID")
End If
%>
<%
Dim CrewForeman
Dim CrewForeman_cmd
Dim CrewForeman_numRows

Set CrewForeman_cmd = Server.CreateObject ("ADODB.Command")
CrewForeman_cmd.ActiveConnection = MM_mande_STRING
CrewForeman_cmd.CommandText = "SELECT Jobs.CrewForeman, Users.UserFirstName, Users.UserLastName FROM Jobs, Users WHERE jobs.clientid = "&Session("clientid")&" and Jobs.JobID = ? AND Jobs.CrewForeman=Users.UserID" 
CrewForeman_cmd.Prepared = true
CrewForeman_cmd.Parameters.Append CrewForeman_cmd.CreateParameter("param1", 5, 1, -1, CrewForeman__MMColParam) ' adDouble

Set CrewForeman = CrewForeman_cmd.Execute
CrewForeman_numRows = 0
crewforemanid = 0
if not CrewForeman.eof then
crewforemanid = CrewForeman("CrewForeman")
end if
%>

<%
Dim PowerWasher__MMColParam
PowerWasher__MMColParam = "1"
If (Request.QueryString("JobID") <> "") Then 
  PowerWasher__MMColParam = Request.QueryString("JobID")
End If
%>
<%
Dim PowerWasher
Dim PowerWasher_cmd
Dim PowerWasher_numRows

Set PowerWasher_cmd = Server.CreateObject ("ADODB.Command")
PowerWasher_cmd.ActiveConnection = MM_mande_STRING
PowerWasher_cmd.CommandText = "SELECT Jobs.PowerWasherAssigned, Users.UserID, Users.UserFirstName, Users.UserLastName FROM Jobs, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? and Jobs.PowerWasherAssigned=Users.UserID" 
PowerWasher_cmd.Prepared = true
PowerWasher_cmd.Parameters.Append PowerWasher_cmd.CreateParameter("param1", 5, 1, -1, PowerWasher__MMColParam) ' adDouble

Set PowerWasher = PowerWasher_cmd.Execute
PowerWasher_numRows = 0
%>
<%
Dim Painters__MMColParam
Painters__MMColParam = "1"
If (Request.QueryString("JobID") <> "") Then 
  Painters__MMColParam = Request.QueryString("JobID")
End If
%>
<%
Dim Painters
Dim Painters_cmd
Dim Painters_numRows

Set Painters_cmd = Server.CreateObject ("ADODB.Command")
Painters_cmd.ActiveConnection = MM_mande_STRING
Painters_cmd.CommandText = "SELECT DISTINCT AddedLabor.PainterID, AddedLabor.PainterFirstName FROM AddedLabor WHERE clientid = "&Session("clientid")&" and AddedLabor.JobID = ?" 
Painters_cmd.Prepared = true
Painters_cmd.Parameters.Append Painters_cmd.CreateParameter("param1", 5, 1, -1, Painters__MMColParam) ' adDouble

Set Painters = Painters_cmd.Execute
Painters_numRows = 0
%>
<%
Dim ReferralTypes
Dim ReferralTypes_cmd
Dim ReferralTypes_numRows

Set ReferralTypes_cmd = Server.CreateObject ("ADODB.Command")
ReferralTypes_cmd.ActiveConnection = MM_mande_STRING
ReferralTypes_cmd.CommandText = "SELECT * FROM Referrals where clientid = "&Session("clientid")&" and ActiveYesNo = 1 ORDER BY ReferralName ASC" 
ReferralTypes_cmd.Prepared = true

Set ReferralTypes = ReferralTypes_cmd.Execute
ReferralTypes_numRows = 0
%>
<%
Dim JobTypes
Dim JobTypes_cmd
Dim JobTypes_numRows

Set JobTypes_cmd = Server.CreateObject ("ADODB.Command")
JobTypes_cmd.ActiveConnection = MM_mande_STRING
JobTypes_cmd.CommandText = "SELECT * FROM EstimateTypes where clientid = "&Session("clientid")&" and ActiveYesNo = 1 ORDER BY EstimateTypeName ASC" 
JobTypes_cmd.Prepared = true

Set JobTypes = JobTypes_cmd.Execute
JobTypes_numRows = 0
%>
<%

%>
<%
if session("UseSubdivisionsYesNo") = True then
Dim SubDivisions
Dim SubDivisions_cmd
Dim SubDivisions_numRows

Set SubDivisions_cmd = Server.CreateObject ("ADODB.Command")
SubDivisions_cmd.ActiveConnection = MM_mande_STRING
SubDivisions_cmd.CommandText = "SELECT * FROM SubDivisions where clientid = "&Session("clientid")&" and ActiveYesNo = 1 ORDER BY SubDivisionName ASC" 
SubDivisions_cmd.Prepared = true

Set SubDivisions = SubDivisions_cmd.Execute
SubDivisions_numRows = 0
end if

Dim EstimatorAssigned
Dim EstimatorAssigned_cmd
Dim EstimatorAssigned_numRows

Set EstimatorAssigned_cmd = Server.CreateObject ("ADODB.Command")
EstimatorAssigned_cmd.ActiveConnection = MM_mande_STRING
EstimatorAssigned_cmd.CommandText = "SELECT UserID,UserFirstName,UserLastName FROM Users where clientid = "&Session("clientid")&" ORDER BY UserFirstName,UserLastName ASC" 
EstimatorAssigned_cmd.Prepared = true

Set EstimatorAssigned = EstimatorAssigned_cmd.Execute
EstimatorAssigned_numRows = 0

Dim CancelReason
Dim CancelReason_cmd
Dim CancelReason_numRows

Set CancelReason_cmd = Server.CreateObject ("ADODB.Command")
CancelReason_cmd.ActiveConnection = MM_mande_STRING
CancelReason_cmd.CommandText = "SELECT CancellationReasonID,CancellationText FROM CancellationReasons where clientid = "&Session("clientid")&" and ActiveYesNo = 1 ORDER BY CancellationText ASC" 
CancelReason_cmd.Prepared = true

Set CancelReason = CancelReason_cmd.Execute
CancelReason_numRows = 0

Dim JobCancelReason
Dim JobCancelReason_cmd
Dim JobCancelReason_numRows

Set JobCancelReason_cmd = Server.CreateObject ("ADODB.Command")
JobCancelReason_cmd.ActiveConnection = MM_mande_STRING
JobCancelReason_cmd.CommandText = "SELECT CancellationReasonID,CancellationText FROM JobCancellationReasons where clientid = "&Session("clientid")&" and ActiveYesNo = 1 ORDER BY CancellationText ASC" 
JobCancelReason_cmd.Prepared = true

Set JobCancelReason = JobCancelReason_cmd.Execute
JobCancelReason_numRowJobs = 0

Dim ContactType
Dim ContactType_cmd
Dim ContactType_numRows

Set ContactType_cmd = Server.CreateObject ("ADODB.Command")
ContactType_cmd.ActiveConnection = MM_mande_STRING
ContactType_cmd.CommandText = "SELECT ContactTypeID,ContactTypeText FROM ContactTypes ORDER BY ContactTypeText ASC" 
ContactType_cmd.Prepared = true

Set ContactType = ContactType_cmd.Execute
ContactType_numRows = 0
%>
<%
Dim Estimator__MMColParam
Estimator__MMColParam = "1"
If (Request.QueryString("JobID") <> "") Then 
  Estimator__MMColParam = Request.QueryString("JobID")
End If
%>
<%
Dim Estimator
Dim Estimator_cmd
Dim Estimator_numRows

Set Estimator_cmd = Server.CreateObject ("ADODB.Command")
Estimator_cmd.ActiveConnection = MM_mande_STRING
Estimator_cmd.CommandText = "SELECT Jobs.JobID,jobs.jobregion, Jobs.EstimatorAssigned,Jobs.JobManagerAssigned, Users.UserID, Users.UserFirstName, Users.UserLastName FROM Jobs, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? and Users.UserID=Jobs.EstimatorAssigned" 
Estimator_cmd.Prepared = true
Estimator_cmd.Parameters.Append Estimator_cmd.CreateParameter("param1", 5, 1, -1, Estimator__MMColParam) ' adDouble

Set Estimator = Estimator_cmd.Execute
estid = Estimator("EstimatorAssigned")
Estimator_numRows = 0


'if not Est.eof then

	jobmanager = Estimator("JobManagerAssigned")'Est("jobmanager")
	if jobmanager <> "" then
		Set jm_cmd = Server.CreateObject ("ADODB.Command")
		jm_cmd.ActiveConnection = MM_mande_STRING
		jm_cmd.CommandText = "SELECT * FROM users where clientid = "&Session("clientid")&" and userid = " & jobmanager
		jm_cmd.Prepared = true	
		
		Set jm = jm_cmd.Execute
		if not jm.eof then
		jfname = jm("userFirstName")
		jlname = jm("userlastName")
		jphone = jm("UserPhone1")
		jemail = jm("UserEmail")
		end if
	end if

'else
	
'	Set jm_cmd = Server.CreateObject ("ADODB.Command")
'		jm_cmd.ActiveConnection = MM_mande_STRING
'		jm_cmd.CommandText = "SELECT * FROM users where userid = " & estid
'		jm_cmd.Prepared = true	
'		Set jm = jm_cmd.Execute
'		jfname = jm("userFirstName")
'		jlname = jm("userlastName")
'		jphone = jm("UserPhone1")
'		jemail = jm("UserEmail")
'		
'end if


body_email1 = replace(body_email1,"[+customername+]",sCustomerFName)
body_email1 = replace(body_email1,"[+datetime+]",dseldate & " " & selstarttime)
body_email1 = replace(body_email1,"[+estimatorfname+]",userfname)
body_email1 = replace(body_email1,"[+estimatorlname+]",userlname)
body_email1 = replace(body_email1,"[+estimatorcell+]",userphone)
body_email1 = replace(body_email1,"[+estimatoremail+]",useremail)
if jobmanager <> "" then
body_email1 = replace(body_email1,"Leo",jfname)
body_email1 = replace(body_email1,"Rodriguez",jlname)
body_email1 = replace(body_email1,"970-388-2120",jphone)
body_email1 = replace(body_email1,"lrodriguez@mandepainting.com",jemail)
end if

body_email1a = replace(body_email1a,"[+customername+]",sCustomerFName)
body_email1a = replace(body_email1a,"[+datetime+]",dseldate & " " & selstarttime)
body_email1a = replace(body_email1a,"[+estimatorfname+]",userfname)
body_email1a = replace(body_email1a,"[+estimatorlname+]",userlname)
body_email1a = replace(body_email1a,"[+estimatorcell+]",userphone)
body_email1a = replace(body_email1a,"[+estimatoremail+]",useremail)
body_email1a = replace(body_email1a,"[+prodmanagerfname+]",produserfname)
body_email1a = replace(body_email1a,"[+prodmanagerlname+]",produserlname)

'Response.Write body_email1a

%>
<%
Dim FirstContact__MMColParam
FirstContact__MMColParam = "1"
If (Request.QueryString("JobID") <> "") Then 
  FirstContact__MMColParam = Request.QueryString("JobID")
End If
%>
<%
Dim FirstContact
Dim FirstContact_cmd
Dim FirstContact_numRows

Set FirstContact_cmd = Server.CreateObject ("ADODB.Command")
FirstContact_cmd.ActiveConnection = MM_mande_STRING
FirstContact_cmd.CommandText = "SELECT Jobs.CreatedByUserID, Users.UserID, Users.UserFirstName, Users.UserLastName FROM Jobs, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? AND Users.UserID=Jobs.CreatedByUserID" 
FirstContact_cmd.Prepared = true
FirstContact_cmd.Parameters.Append FirstContact_cmd.CreateParameter("param1", 5, 1, -1, FirstContact__MMColParam) ' adDouble

Set FirstContact = FirstContact_cmd.Execute
FirstContact_numRows = 0

Dim FirstContact1
Dim FirstContact1_cmd
Dim FirstContact1_numRows

Set FirstContact1_cmd = Server.CreateObject ("ADODB.Command")
FirstContact1_cmd.ActiveConnection = MM_mande_STRING
FirstContact1_cmd.CommandText = "SELECT Jobs.JobManagerAssigned, Users.UserID, Users.UserFirstName, Users.UserLastName FROM Jobs, Users WHERE jobs.clientid = "&Session("clientid")&" and JobID = ? AND Users.UserID=Jobs.JobManagerAssigned" 
FirstContact1_cmd.Prepared = true
FirstContact1_cmd.Parameters.Append FirstContact_cmd.CreateParameter("param1", 5, 1, -1, FirstContact__MMColParam) ' adDouble

Set FirstContact1 = FirstContact1_cmd.Execute
if not FirstContact1.eof then
	prodmanager = FirstContact1("UserFirstName") & " " & FirstContact1("UserLastName")
	prodmanagerid = FirstContact1("Userid")
end if

FirstContact1_numRows = 0

%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Painters_numRows = Painters_numRows + Repeat1__numRows
%>

Open in new window


Thanks again for your assistance!

Bill
0
 
LVL 5

Expert Comment

by:R. Toby Richards
Comment Utility
I don't know ASP. I'm A PHP guy, so I just know the theory of what may be wrong. I do think that since the database is getting updated that the problem must be the code, so it's time to repost this question under programming / ASP or programming / MS development.
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
This question is already posted 3x .. start hyper-v or some other virtual machine and use the previous operating system and settings and see if your code works there.
0
 
LVL 1

Author Comment

by:billium99
Comment Utility
Sorry David - I got bounced around with suggestions on where it should have been posted.

This exact code worked great in the old environment, so unless you can think of a reason why a duplicate on new hardware should be run through a simulated-old environment to see if it works, I'd like to forgo that step. There is very little doubt in my mind that this is an IIS/ASP/MS SQL configuration issue.

Thanks

Bill
0
 
LVL 1

Author Closing Comment

by:billium99
Comment Utility
Too many threads - thanks for the help. Not resolved yet...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now