All pastes #909841 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-02-19 15:40 UTC
rendered paste body

if($_GET['CompanyID'])
{
	if(is_numeric($_GET['CompanyID']))
		$companyID = $_GET['CompanyID'];
	else
		die("Invalid Company ID.");

	$body = "";
	$sqlQuery = "SELECT C1.ID,C1.Deleted FROM dbo.Company C1 WHERE (C1.Deleted=1 AND C1.ID=".$companyID.")";
	$process=@odbc_exec($sqlconnect, $sqlQuery);
	if (@odbc_error()) 
		echo @odbc_errormsg($sqlconnect);
	else
	{
		odbc_fetch_row($process);
		if(odbc_result($process, 2)==1)
		{
			$inactive = true;
			$sqlQuery = "SELECT Name FROM Company WHERE (ID = ".$companyID.")";
			if (@odbc_error()) 
				echo @odbc_errormsg($sqlconnect);
			else
			{
				odbc_fetch_row($process);
				$cName = htmlspecialchars(odbc_result($process, 1));
			}
			$body .= '<table width=100% bgcolor="#cccccc"><tr><TD>
				<P><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><BR><BR>
				<span class=bodybold>  <BR><BR><BR>
				<B><u>'.$cName.'</u> is Currently Inactive.</B></span>
				<P>
	<FORM METHOD=POST ACTION="customer.php?CompanyID='.$companyID.'&active=1">

	<INPUT TYPE=SUBMIT NAME="Submit" VALUE="MAKE CUSTOMER ACTIVE" style="font-size: 10; font-family: Verdana; Arial; Helvetica">
	</FORM>
	<BR>
	<font size="1" face="Verdana, Arial, Helvetica, sans-serif">
	Note: This will make all contact and vehicles for that customer active as well.  To inactivate certain
	vehicles and/or contacts associated to this company you must do that manually for each vehicle/contact.
	<P>
	

	<FORM METHOD=POST ACTION="'.$_SERVER[PHP_SELF].'">

	<INPUT TYPE=SUBMIT NAME="Submit" VALUE="LEAVE INACTIVE" style="font-size: 10; font-family: Verdana; Arial; Helvetica">
	</FORM>

<BR><BR><BR>';
	}

	$sqlQuery = "SELECT 
C1.ID,C1.Name,C1.BillAddress,C1.BillAddress2,C1.BillCity,C1.BillState,C1.BillZip,C1.MainPhone,C1.MainFax,C1.Website,C2.ContactID,C1.DateCreated,C1.CompanyTyp

eID,C1.CreatedBy,C1.Deleted,C1.Notes,C2.ContactName,C2.Title,C2.Address1,C2.Address2,C2.City,C2.State,C2.Zip,C2.Phone,C2.MobilePhone,C2.Fax,C2.PrimaryContact

,C2.Email,C1.VendorMarkup,C1.Terms FROM dbo.Company C1,dbo.Contacts C2 WHERE (C1.ID=".$companyID." AND C2.PrimaryContact=1) AND ((C2.CompanyID=C1.ID))";
	$process=@odbc_exec($sqlconnect, $sqlQuery);
	if (@odbc_error()) 
		echo @odbc_errormsg($sqlconnect);
	else
	{
		odbc_fetch_row($process);
		$body .= '<table width=100%  border=0 bordercolor="#999999" bgcolor="#cccccc">
<TR ALIGN="LEFT" VALIGN="TOP">
	<TD>
	<font size="3" face="Verdana, Arial, Helvetica, sans-serif">
	<font color=#cc0033><b>'.htmlspecialchars(odbc_result($process, 2)).'</b></font><BR>
	<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Account Number: '.htmlspecialchars(odbc_result($process, 36)).'<BR>
	<font size="2" face="Verdana, Arial, Helvetica, sans-serif">
	<B>'.htmlspecialchars(odbc_result($process, 23)).(odbc_result($process, 4)=="" ? "" : "<br />".htmlspecialchars(odbc_result($process, 4))).'</b><BR>
	<B>'.htmlspecialchars(odbc_result($process, 5)).', '.htmlspecialchars(odbc_result($process, 6)).' '.htmlspecialchars(odbc_result($process, 

7)).'</b><BR>
	<B>Tel.</b> '.htmlspecialchars(odbc_result($process, 8)).' <b>Fax.</b> '.htmlspecialchars(odbc_result($process, 9)).'
	<BR>
	<b>Website:</b> '.htmlspecialchars(odbc_result($process, 10)).'
	<B>Standard PM Cycle:</b> '.htmlspecialchars(odbc_result($process, 29)).' Days<BR>
	
	<B>Customer Record Created:</b> '.date("m-d-y", strtotime(odbc_result($process, 2))).'<BR>
		
	</TD>
	
	<TD valign=Top Width=20%>
	</TD>
	
	<TD valign=Top><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
	<B>PRIMARY CONTACT</B><BR>
	<B>'.htmlspecialchars(odbc_result($process, 16)).'</B><BR>
	
	<B>'.htmlspecialchars(odbc_result($process, 18)).(odbc_result($process, 4)=="" ? "" : "<br />".htmlspecialchars(odbc_result($process, 19))).'</b><BR>
	
	<B>'.htmlspecialchars(odbc_result($process, 20)).',  '.htmlspecialchars(odbc_result($process, 21)).'  '.htmlspecialchars(odbc_result($process, 

22)).'</b><BR>
	<B>Tel. </b>'.htmlspecialchars(odbc_result($process, 23)).' <b>Mobile. </b>'.htmlspecialchars(odbc_result($process, 24)).'<br />
	<b>Fax. </b>'.htmlspecialchars(odbc_result($process, 25)).'<br />
	<b>Email </b>'.htmlspecialchars(odbc_result($process, 28)).'<br />
	<BR><BR></TD></TR>';
	}

	$sqlQuery = "SELECT Name,PerInvoiceLimit,StatusDescription from BSCustomers where FDCompanyID=".$companyID;
	$process=@odbc_exec($sqlconnect, $sqlQuery);
	if (@odbc_error()) 
		echo @odbc_errormsg($sqlconnect);
	else
	{
		odbc_fetch_row($process);
		$body .= '<TR>
			<td colspan=3>	
		<TABLE BORDER=0>
		<tr>
		<td colspan=3 style="background-color : #A9A9A9;">
					</td>
		</tr>

		<TR>
		<TH class="blackbold" size=2 style="background-color : #A9A9A9;">Billing Service</TH>
		<TH class="blackbold" size=2 style="background-color : #A9A9A9;">Per/Invoice Limit</TH>
		<TH class="blackbold" size=2 style="background-color : #A9A9A9;">Status</TH>
		</TR>
				<TR>
				<TD  class="REDBOLD" style="background-color : #D3D3D3;">'.htmlspecialchars(odbc_result($process, 1)).'</TD>
				<TD  class="REDBOLD" style="background-color : #D3D3D3;">$'.htmlspecialchars(odbc_result($process, 2)).'</TD>
				<TD  class="REDBOLD" style="background-color : #D3D3D3;">'.htmlspecialchars(odbc_result($process, 3)).'</TD>
		</TR>
		</TABLE>
	<br>
	</td></TR>
<TR><td colspan=3><BR><BR></TD></TR>';
	}

	if(!$inactive)
	{
		$sqlQuery = "SELECT C1.ContactID,C1.ContactName,C1.Deleted FROM Contacts C1 WHERE (C1.ContactType=3 AND C1.IsEmployee=1 AND C1.SalesPerson=1) 

ORDER BY 2 ASC";
		$process=@odbc_exec($sqlconnect, $sqlQuery);
		if (@odbc_error()) 
			echo @odbc_errormsg($sqlconnect);
		else
		{
			$body .= '<TR>
	<TD Colspan=2>
	<FORM METHOD=POST ACTION="customer.php?_function=detail&companyID='.$companyID.'&_action=update_sales">
	<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><B>Sales Rep:</B> <SELECT NAME="repID" SIZE="1">
<OPTION Class="optiongrey" VALUE="" SELECTED>-- Make Selection --&nbsp;</OPTION>';

			while(odbc_fetch_row($process))
				$body .= '<OPTION Class="optiongrey" VALUE="'.htmlspecialchars(odbc_result($process, 1)).'"> 

'.htmlspecialchars(odbc_result($process, 2)).(odbc_result($process, 3)==1 ? "(inactive)" : "").'</OPTION>';

			$body .= '</SELECT></FORM></TD></TR>';
		}
	}
	$body .= '</TABLE>';

	$sqlQuery = "SELECT 

V1.ID,V1.CompanyID,V1.License,V1.FleetNumber,V1.Make,V1.Model,V1.State,V1.Year,V2.Make,V3.Model,V1.DOTRequired,V1.LastPM,V1.NextPM,V1.LastDOT,V1.NextDOT,V1.V

IN FROM Vehicles V1,Vehicle_Make V2,Vehicle_Model V3 WHERE (V1.CompanyID=".$companyID.") AND ((V2.ID=V1.Make) AND (V3.ID=V1.Model)) ORDER BY 3 ASC";
	$process=@odbc_exec($sqlconnect, $sqlQuery);
	if (@odbc_error()) 
		echo @odbc_errormsg($sqlconnect);
	else
	{
		$x = 0;
		$vehicleData = "";
		while(odbc_fetch_row($process))
		{
			$vehicleData .= '<TR bgcolor="#FFFFFF" height=20>
	<TD CLASS=BODYBLACK>('.$x.'.)</TD>
	<TD CLASS=BODYBLACK>'.htmlspecialchars(odbc_result($process, 3)).(odbc_result($process, 4)=="" ? "" : "#".htmlspecialchars(odbc_result($process, 

4))).'  </TD>
	<TD CLASS=BODYBLACK>'.htmlspecialchars(odbc_result($process, 16)).'</TD>
	<TD CLASS=BODYBLACK>'.htmlspecialchars(odbc_result($process, 9)).'</TD>
	<TD CLASS=BODYBLACK>'.htmlspecialchars(odbc_result($process, 10)).'</TD>
	<TD CLASS=BODYBLACK>'.htmlspecialchars(odbc_result($process, 8)).' / '.htmlspecialchars(odbc_result($process, 7)).'</TD>
	<TD CLASS=BODYBLACK>'.(odbc_result($process, 12)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 12))).' | '.(odbc_result($process, 

13)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 13))).'</TD>
	<TD CLASS=BODYBLACK>'.(odbc_result($process, 14)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 14))).' | '.(odbc_result($process, 

15)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 15))).'</TD>
	<TD CLASS=BODYBLACK><A HREF="vehicle.php?Vehicle='.htmlspecialchars(odbc_result($process, 1)).'&company='.htmlspecialchars(odbc_result($process, 

2)).'">View</a> | <a href="add_vehicle.php?_function=update&companyid='.htmlspecialchars(odbc_result($process, 

2)).'&vehicleid='.htmlspecialchars(odbc_result($process, 1)).'">Update</a> </TD>
</TR>';
			$x++;	
		}

		$body .= '<table width=100%  border=0 bordercolor="#999999" bgcolor="#cccccc">
<TR VALIGN="TOP">
	<TD bgcolor=#666666>
	<font size="2" color="#ffffff" face="Verdana, Arial, Helvetica, sans-serif">
	&nbsp;<b>Vehicle Summary:</b> 
	</TD>
</TR>
</Table>


<table width=100%  border=0 bordercolor="#999999" bgcolor="#cccccc">

<TR>
	<TD colspan=2>
	<span class=bodyblack>
<BR><BR>
	There is <B>'.$x.'</B> Vehicle Active.

<BR><BR>

<TABLE BORDER=0 width=100% class=onepixborder>

<TR>
	<th class="BODYBLACK" align=left></TH>
	<TH class=BODYBLACK>License|FLT#</TH>
	<TH class=BODYBLACK>VIN</TH>
	<TH class=BODYBLACK>Make</TH>
	<TH class=BODYBLACK>Model</TH>
	<TH class=BODYBLACK>Year|State</TH>
	<TH class=BODYBLACK>LastPM|Next<span class=bodyblack>
	<TH class=BODYBLACK>LastDOT|Next</TH>
</TR>'.$vehicleData.'</Table><BR><BR></td></tr></table>';
	}
		
	$body .= '<table border=0 cellspacing="0" cellpadding="2">
		<tr><td align="center" valign="top">		
		<span class="blackBold">Job Code Service Stats:</span><BR>';

	$sqlQuery = "sp_Full_Report_JCSvc '%',12996,'%','%','%','%',0,0,0";
	$process=@odbc_exec($sqlconnect, $sqlQuery);
	if (@odbc_error()) 
		echo @odbc_errormsg($sqlconnect);
	else
	{
		if(odbc_num_rows($process)==0)
			$body .= '<span class="redbold">NO RESULTS FOUND.<BR></span>';
		else
		{
			$body .= '<span class="bodyboldblack">Company: 3 P DELIVERY INC. / ARI<BR></span>
		<table class="onepixborder" width=100%>
		<TR bgcolor="#999999">
			<th class="bluebold" align=left colspan=2 nowrap>&nbsp; Job Code</TH>	
			<th class="bluebold" align=Center nowrap>&nbsp; Never &nbsp;</TH>
			<th class="bluebold" align=Center nowrap>&nbsp; 1-30 &nbsp;</TH>
			<th class="bluebold" align=Center nowrap>&nbsp; 31-60 &nbsp;</TH>
			<th class="bluebold" align=Center nowrap>&nbsp; 61-90 &nbsp;</TH>
			<th class="bluebold" align=Center nowrap>&nbsp; 91-120 &nbsp;</TH>
			<th class="bluebold" align=Center nowrap>&nbsp; Over-121 &nbsp;</TH>
		</TR>';

			$x = 0;
			while(odbc_fetch_row($process))
			{
				if(fmod($x, 2)==0)
					$bgColor = "#FFFFFF";
				else
					$bgColor = "#CCCCFF";

				$body .= '<TR bgcolor="'.$bgColor.'">												

			<TD class="bodyblack" align=left Colspan=2 bgcolor="#FFFFFF">'.htmlspecialchars(odbc_result($process, 2)).'</TD>
			<TD class="bodyblack" align=center>'.(odbc_result($process, 4)==0 ? "-" : '<a 

href="report_jcsvc.php?detail=1&DayRngStart=91&DayRngStop=120&JobCodeID=3&companyID=&vehicleID=&makeID=&modelID=&typeID="><b>'.htmlspecialchars(odbc_result($

process, 4)).'</b></a>').</TD>
			<TD class="bodyblack" align=center>'.(odbc_result($process, 5)==0 ? "-" : '<a 

href="report_jcsvc.php?detail=1&DayRngStart=91&DayRngStop=120&JobCodeID=3&companyID=&vehicleID=&makeID=&modelID=&typeID="><b>'.htmlspecialchars(odbc_result($

process, 5)).'</b></a>').</TD>
			<TD class="bodyblack" align=center>'.(odbc_result($process, 6)==0 ? "-" : '<a 

href="report_jcsvc.php?detail=1&DayRngStart=91&DayRngStop=120&JobCodeID=3&companyID=&vehicleID=&makeID=&modelID=&typeID="><b>'.htmlspecialchars(odbc_result($

process, 6)).'</b></a>').</TD>
			<TD class="bodyblack" align=center>'.(odbc_result($process, 7)==0 ? "-" : '<a 

href="report_jcsvc.php?detail=1&DayRngStart=91&DayRngStop=120&JobCodeID=3&companyID=&vehicleID=&makeID=&modelID=&typeID="><b>'.htmlspecialchars(odbc_result($

process, 7)).'</b></a>').</TD>
			<TD class="bodyblack" align=center>'.(odbc_result($process, 8)==0 ? "-" : '<a 

href="report_jcsvc.php?detail=1&DayRngStart=91&DayRngStop=120&JobCodeID=3&companyID=&vehicleID=&makeID=&modelID=&typeID="><b>'.htmlspecialchars(odbc_result($

process, 8)).'</b></a>').</TD>
			<TD class="bodyblack" align=center>'.(odbc_result($process, 9)==0 ? "-" : '<a 

href="report_jcsvc.php?detail=1&DayRngStart=91&DayRngStop=120&JobCodeID=3&companyID=&vehicleID=&makeID=&modelID=&typeID="><b>'.htmlsp8cialchars(odbc_result($

process, 9)).'</TD>
			</TR>';	
			}
			$body .= '</Table></td></TR></Table><BR><BR><BR>';
		}
	}

	$body .= '<script language="javascript">
<!--
function invOpenWin_onclick(url)
{
   var winTop = (screen.height / 2) - 110;
   var winLeft = (screen.width / 2) - 75;
   var windowFeatures = "width=845,height=550,scrollbars,";
   windowFeatures = windowFeatures + "left=" + winLeft + ",";
   windowFeatures = windowFeatures + "top=" + winTop;
   newWindow = window.open(url,"myWindow2",windowFeatures);
}

!-->
</script>
<table  width=100% border=0 cellspacing="0" cellpadding="2" bgcolor="#666666">
<tr>
	<td align="center" valign="top"><font size="1" color="#666666" face="Verdana, Arial, Helvetica, sans-serif">
	<font color="#ffffff"><B>
		
		
		Service History: Showing Most Recent 50
		</b><table width=100%  border=0 bordercolor="#666666" cellspacing="3" cellpadding="0" bgcolor="#FFFFFF" align="right">

		<!--- White Background Text --->
		<TR>


			<TD><font size="1" color="#666666" face="Verdana, Arial, Helvetica, sans-serif">
			<B>Date
			</TD>
			
			
			<TD><font size="1" color="#666666" face="Verdana, Arial, Helvetica, sans-serif">
			<B>Status
			</TD>


			
			<TD><font size="1" color="#666666" face="Verdana, Arial, Helvetica, sans-serif">
			<B>WO/Inv #
			</TD>

			<TD><font size="1" color="#666666" face="Verdana, Arial, Helvetica, sans-serif">
			<B>Title
			</TD>
			
			<TD><font size="1" color="#666666" face="Verdana, Arial, Helvetica, sans-serif">
			<B>Mileage
			</TD>

			<TD><font size="1" color="#666666" face="Verdana, Arial, Helvetica, sans-serif">
			<B>

			Lic / Flt#

			</TD>

		</TR>
		<TR>
			<TD COLSPAN=6>
			<HR NOSHADE>
			</TD>
		</TR>';

	$body .= printServiceHistory($sqlconnect);

	$body .= '</Table>
	</td>
</TR>
</Table>
<BR>


	</TD>
</TR>


</TABLE>
 
<table width=100% border=0 bordercolor="#999999" bgcolor="#cccccc">


<TR VALIGN="TOP">
	<TD bgcolor="#666666">
	<font size="2" color="#ffffff" face="Verdana, Arial, Helvetica, sans-serif">
	&nbsp;<b>Company Notes:</b></font>		
	</TD>
</TR>

<TR VALIGN="TOP">
	<TD>
		
			<TR>
			<TD align=left valign=top nowrap colspan=2><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
			<B>** No Notes on this customer **</b>
			</TD>

		</TR>
	
		

<table width=100% border=0 bordercolor="#999999" bgcolor="#cccccc">
		<TR>
			<TD>
				<P><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
				<B>Add New Note:</b>
			</TD>
		</TR>
		
		
		<TR>
			<TD align=left valign=top><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
			
			<FORM METHOD=POST ACTION="customer.php?_function=detail&Vehicle=&company='.$companyID.'&action=add">
			<TEXTAREA Class="optiongrey" ROWS=7 COLS=60 WRAP=VIRTUAL  NAME="notes"></TEXTAREA>
			<P>
			<INPUT TYPE=SUBMIT NAME="Submit" VALUE="Add Note" style="font-size: 10; font-family: Verdana; Arial; Helvetica">
			</FORM>
			</td>
		</TR>
	</Table>


 
 


			</TD>

			</TR>
		</TABLE>';
		
}