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 .= ''; $x++; } $body .= '






'.$cName.' is Currently Inactive.


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.




'; } $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 .= ''; } $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 .= ''; } 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 .= ''; } } $body .= '
'.htmlspecialchars(odbc_result($process, 2)).'
Account Number: '.htmlspecialchars(odbc_result($process, 36)).'
'.htmlspecialchars(odbc_result($process, 23)).(odbc_result($process, 4)=="" ? "" : "
".htmlspecialchars(odbc_result($process, 4))).'

'.htmlspecialchars(odbc_result($process, 5)).', '.htmlspecialchars(odbc_result($process, 6)).' '.htmlspecialchars(odbc_result($process, 7)).'
Tel. '.htmlspecialchars(odbc_result($process, 8)).' Fax. '.htmlspecialchars(odbc_result($process, 9)).'
Website: '.htmlspecialchars(odbc_result($process, 10)).' Standard PM Cycle: '.htmlspecialchars(odbc_result($process, 29)).' Days
Customer Record Created: '.date("m-d-y", strtotime(odbc_result($process, 2))).'
PRIMARY CONTACT
'.htmlspecialchars(odbc_result($process, 16)).'
'.htmlspecialchars(odbc_result($process, 18)).(odbc_result($process, 4)=="" ? "" : "
".htmlspecialchars(odbc_result($process, 19))).'

'.htmlspecialchars(odbc_result($process, 20)).', '.htmlspecialchars(odbc_result($process, 21)).' '.htmlspecialchars(odbc_result($process, 22)).'
Tel. '.htmlspecialchars(odbc_result($process, 23)).' Mobile. '.htmlspecialchars(odbc_result($process, 24)).'
Fax. '.htmlspecialchars(odbc_result($process, 25)).'
Email '.htmlspecialchars(odbc_result($process, 28)).'


Billing Service Per/Invoice Limit Status
'.htmlspecialchars(odbc_result($process, 1)).' $'.htmlspecialchars(odbc_result($process, 2)).' '.htmlspecialchars(odbc_result($process, 3)).'



Sales Rep:
'; $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 .= '
('.$x.'.) '.htmlspecialchars(odbc_result($process, 3)).(odbc_result($process, 4)=="" ? "" : "#".htmlspecialchars(odbc_result($process, 4))).' '.htmlspecialchars(odbc_result($process, 16)).' '.htmlspecialchars(odbc_result($process, 9)).' '.htmlspecialchars(odbc_result($process, 10)).' '.htmlspecialchars(odbc_result($process, 8)).' / '.htmlspecialchars(odbc_result($process, 7)).' '.(odbc_result($process, 12)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 12))).' | '.(odbc_result($process, 13)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 13))).' '.(odbc_result($process, 14)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 14))).' | '.(odbc_result($process, 15)=="NULL" ? "N/A" : htmlspecialchars(odbc_result($process, 15))).' View | Update
 Vehicle Summary:


There is '.$x.' Vehicle Active.

'.$vehicleData.'
License|FLT# VIN Make Model Year|State LastPM|Next LastDOT|Next


'; } $body .= '
Job Code Service Stats:
'; $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 .= 'NO RESULTS FOUND.
'; else { $body .= 'Company: 3 P DELIVERY INC. / ARI
'; $x = 0; while(odbc_fetch_row($process)) { if(fmod($x, 2)==0) $bgColor = "#FFFFFF"; else $bgColor = "#CCCCFF"; $body .= ''; } $body .= '
  Job Code   Never     1-30     31-60     61-90     91-120     Over-121  
'.htmlspecialchars(odbc_result($process, 2)).' '.(odbc_result($process, 4)==0 ? "-" : ''.htmlspecialchars(odbc_result($ process, 4)).''). '.(odbc_result($process, 5)==0 ? "-" : ''.htmlspecialchars(odbc_result($ process, 5)).''). '.(odbc_result($process, 6)==0 ? "-" : ''.htmlspecialchars(odbc_result($ process, 6)).''). '.(odbc_result($process, 7)==0 ? "-" : ''.htmlspecialchars(odbc_result($ process, 7)).''). '.(odbc_result($process, 8)==0 ? "-" : ''.htmlspecialchars(odbc_result($ process, 8)).''). '.(odbc_result($process, 9)==0 ? "-" : ''.htmlsp8cialchars(odbc_result($ process, 9)).'



'; } } $body .= '
Service History: Showing Most Recent 50 '; $body .= printServiceHistory($sqlconnect); $body .= '
Date Status WO/Inv # Title Mileage Lic / Flt#


 Company Notes:
** No Notes on this customer **

Add New Note:

'; }