MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/bosweb/b1705/absoluteresultstechnologies.net/public_html/runtoglory.com/
File Upload :
Current < : /hermes/bosweb/b1705/absoluteresultstechnologies.net/public_html/runtoglory.com/index.php

<?php
	session_start();
	
	if(isset($_GET['sort']))
	{
		
		header("location: index.php");
		exit;
		if($_SESSION['runtoglorydecchallenge']['sort'] == $_GET['sort']) $_SESSION['runtoglorydecchallenge']['sortASC'] = !$_SESSION['runtoglorydecchallenge']['sortASC'];
		else 
		{
			if(in_array($_GET['sort'],array('salesperson'))) $_SESSION['runtoglorydecchallenge']['sortASC'] = false;
			else $_SESSION['runtoglorydecchallenge']['sortASC'] = true;
		}
		
		
		$_SESSION['runtoglorydecchallenge']['sort'] = $_GET['sort'];
		header("location: index.php");
		exit;
	}
	
	if(!isset($_SESSION['runtoglorydecchallenge']['sort'])) $_SESSION['runtoglorydecchallenge']['sort'] = 'dealer';
	if(!isset($_SESSION['runtoglorydecchallenge']['sortASC'])) $_SESSION['runtoglorydecchallenge']['sortASC'] = true;
	include_once('mysqlUtils.php');
	
	$names = array("Marian Solomon","Kristina Chung","Paige Chen","Sherri Melton","Gretchen Hill","Karen Puckett","Patrick Song","Elsie Hamilton","Hazel Bender","Malcolm Wagner","Dolores McLaughlin","Francis McNamara","Sandy Raynor","Marion Moon","Beth Woodard","Julia Desai","Jerome Wallace","Neal Lawrence","Jean Griffin","Kristine Dougherty","Crystal Powers","Alex May","Eric Steele","Wesley Teague");
	$names2 = array("Vernon Gibbs","Todd Connolly","Roger Hansen","Suzanne Dickerson","Thelma Reilly","Danny Fitzpatrick","Betsy Brandon","Teresa Kay","Katherine Berry","Sidney Keith","Elizabeth Andrews","Anna Owens","Marcia Sutton","Cameron Beach","Stacy Ferguson","Brad Silverman","Kara Simmons","Colleen Buchanan","Luis Scott","Phyllis Short","Juanita Lin","Kyle Finley","Lynn Prince","Terri Franklin","Beverly McLaughlin","Vanessa Kahn","Annette White","Lillian Burch");
	foreach($names2 as $key => $name)
	{
		$sql = 'INSERT runtoglorydecchallenge_salesperson (name) values ("' . $names2[$key] . '")';
		
		$fl = explode(" ",$name);
		$sql2 = 'INSERT INTO runtoglorydecchallenge_sales (firstname,
											lastname,
											postalCode,
											phone,
											year,
											description,
											newUsed,
											salesman) VALUES ("' . $fl[0] . '",
															  "' . $fl[1] . '",
															  "",
															  "",
															  "",
															  "",
															  "",
															  "' . rand(85,112) . '")'; 
		
		//mysql_query($sql2);
	}
	
	
	
	$start = '2009-08-01';
	$end = '2009-08-31';
	if($end < date('Y-m-d')) $today = 31;
	else if($start < date('Y-m-d')) $today = date('d');
	else $today = 1;
	
	//$today = 16;
	
	$salespersonResults = mysql_query('SELECT * FROM runtoglorydecchallenge_salesperson');
	$salesArray = array();
	$caraSalesArray = array();
	$totalSales = 0;
	$totalGoals = 0;
	$totalPace = 0;
	$totalCaraSales = 0;
	$totalCaraGoals = 0;
	$totalCaraPace = 0;
	$top = 0;
	
	$dealerships = array('tilbury','chatham','provincial','bayview','leamington','racicot','windsor','pinnacle','countryside','willison','demeyere','eichenberg');
	$flashVar = "";
	foreach($dealerships as $dealer)
	{
		$t = $dealer.'Total';
		$$t = 0;
		
		$caraT = $dealer.'CaraTotal';
		$$caraT = 0;
	}
	
	while($salesperson = mysql_fetch_assoc($salespersonResults))
	{
		$salesArray[$salesperson['salespersonID']]['info'] = $salesperson;
		$salesArray[$salesperson['salespersonID']]['count'] = 0;
		$totalGoals += $salesperson['goal'];
		
		$caraSalesArray[$salesperson['salespersonID']]['info'] = $salesperson;
		$caraSalesArray[$salesperson['salespersonID']]['count'] = 0;
		$totalcaraGoals += $salesperson['goal'];
	}
		
	$salesResults = mysql_query('SELECT salesman, count(*) as salesmanCount FROM runtoglorydecchallenge_sales GROUP BY salesman');
	while($sales = mysql_fetch_assoc($salesResults))
	{
		$salesArray[$sales['salesman']]['count'] += $sales['salesmanCount'];
		$totalSales += $sales['salesmanCount']; 
	}
	
	foreach($salesArray as $salesmanID => $info)
	{
		//$salesArray[$salesmanID]['pace'] = $info['count'] - floor(($info['info']['goal'] / 31) * ($today));
		$salesArray[$salesmanID]['pace'] = $info['count'] - $info['info']['goal'];
		$totalPace += $salesArray[$salesmanID]['pace'];		
		if($info['count'] > $top) $top = $info['count'];
		
		
		foreach($dealerships as $dealer)
		{
			$t = $dealer.'Total';
			if($info['info']['dealer'] == $dealer) $$t += $info['count'];
		}
	}
	
	foreach($dealerships as $dealer)
	{
		$t = $dealer.'Total';
		$flashVar .=  $dealer . 'Sold=' . $$t . '&';
	}
	
	/////////////////////
	/*CARAVAN COUNT*/
	////////////////////
	
	$caraSalesResults = mysql_query('SELECT salesman, count(*) as salesmanCount FROM runtoglorydecchallenge_sales WHERE description like "%ram%" GROUP BY salesman');
	while($caraSales = mysql_fetch_assoc($caraSalesResults))
	{
		$caraSalesArray[$caraSales['salesman']]['count'] += $caraSales['salesmanCount'];
		$totalCaraSales += $caraSales['salesmanCount']; 
	}
	
	foreach($caraSalesArray as $caraSalesmanID => $caraInfo)
	{
		$caraSalesArray[$caraSalesmanID]['pace'] = $caraInfo['count'] - $caraInfo['info']['goal'];
		$totalcaraPace += $caraSalesArray[$caraSalesmanID]['pace'];		
		if($caraInfo['count'] > $caraTop) $caraTop = $caraInfo['count'];
		
		
		foreach($dealerships as $dealer)
		{
			$caraT = $dealer.'CaraTotal';
			if($caraInfo['info']['dealer'] == $dealer) $$caraT += $caraInfo['count'];
		}
	}
	
	foreach($dealerships as $dealer)
	{
		$caraT = $dealer.'CaraTotal';
		$flashVar .=  $dealer . 'CaraSold=' . $$caraT . '&';
	}
	
	$flashVar .= 'caraTotalSold=' . $totalCaraSales . '&';
	
	/////////////////////
	/*END CARAVAN COUNT*/
	////////////////////
	//$flashVar .=  'appointments=' . file_get_contents("http://96.53.92.6:8080/appointments/index.php?e=runtoglorydecchallenge&getTotal=") . '&';
	$flashVar .=  'appointments=0&';
	
	function salesSort($a,$b)
	{		
		if($_SESSION['runtoglorydecchallenge']['sortASC'])
		{
			if($_SESSION['runtoglorydecchallenge']['sort'] == 'salesperson') return $a['info']['name'] < $b['info']['name'];
			else if($_SESSION['runtoglorydecchallenge']['sort'] == 'dealer')
			{
				if($a['info']['dealer'] == $b['info']['dealer']) return $a['count'] < $b['count'];
				return $a['info']['dealer'] < $b['info']['dealer'];
			}
			else if($_SESSION['runtoglorydecchallenge']['sort'] == 'goal') return $a['info']['goal'] < $b['info']['goal'];
			else if($_SESSION['runtoglorydecchallenge']['sort'] == 'sales') return $a['count'] < $b['count'];
			else return $a['pace'] < $b['pace'];
		}
		else
		{
			if($_SESSION['runtoglorydecchallenge']['sort'] == 'salesperson') return $a['info']['name'] > $b['info']['name'];
			else if($_SESSION['runtoglorydecchallenge']['sort'] == 'dealer')
			{
				if($a['info']['dealer'] == $b['info']['dealer']) return $a['count'] > $b['count'];
				return $a['info']['dealer'] > $b['info']['dealer'];
			}
			else if($_SESSION['runtoglorydecchallenge']['sort'] == 'goal') return $a['info']['goal'] > $b['info']['goal'];
			else if($_SESSION['runtoglorydecchallenge']['sort'] == 'sales') return $a['count'] > $b['count'];
			else return $a['pace'] > $b['pace'];
		}
	}
	
	function dateDiff($startDate, $endDate) 
	{ 
	    // Parse dates for conversion 
	    $startArry = date_parse($startDate); 
	    $endArry = date_parse($endDate); 
	
	    // Convert dates to Julian Days 
	    $start_date = gregoriantojd($startArry["month"], $startArry["day"], $startArry["year"]); 
	    $end_date = gregoriantojd($endArry["month"], $endArry["day"], $endArry["year"]); 
	
	    // Return difference 
	    return round(($end_date - $start_date), 0); 
	} 

	usort($salesArray,"salesSort");
	
	if($_SESSION['runtoglorydecchallenge']['sortASC']) $sortIcon = '<small>&#9660;</small>';
	else $sortIcon = '<small>&#9650;</small>';	
	
	include_once('header.php');
?>
<style>	
	.formTbl th {color:#eeeeee;text-align:left;font-size:10pt;vertical-align:middle;padding:5px 5px;font-weight:normal}
	.formTbl input {font-size:8pt}
	.headerTbl {}
	.headerTbl a{color:white;text-decoration:none;}
	.pageTbl a,.listTbl a {color:white;text-decoration:none;font-weight:bold}
	.pageTbl td {width:20px;text-align:center;font-weight:bold}
	.listTbl {width:800px;;}
	.listTbl th {color:#eeeeee;background-image:url('images/thBG.jpg');font-size:9pt;height:20px;vertical-align:middle}
	.listTbl td {color:white;border-bottom:1px solid #cccccc;height:30px;vertical-align:middle;text-align:center}
	.addTbl td {padding:5px 10px 5px 0px;text-align:left}
	.addTbl td input {width:200px}
</style>
<script>
	function move() 
	{
		window.location.reload();
	}
</script>
<body onload="timer=setTimeout('move()',60000)">
<table cellspacing="0" cellpadding="0" class="contentTbl">
	<tr>
		<td style="">
			<table cellspacing="0" cellpadding="0" style="width:100%">
				<tr>
					<td style="text-align:center;float:center;">
						<!--
						<br><br>
						<img src="images/challenger.jpg" usemap="#arlink" border="0">
						<map name="arlink">
  							<area shape="rect" coords="201,59,349,110" href="http://www.absoluteresults.com" alt="Sun" />
  						</map>
						<br><br>
						-->
						<script language="JavaScript" type="text/javascript">
							AC_FL_RunContent(
								'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
								'width', '900',
								'height', '1000',
								'src', 'scoreboard2',
								'quality', 'high',
								'pluginspage', 'http://www.adobe.com/go/getflashplayer',
								'align', 'middle',
								'play', 'true',
								'loop', 'true',
								'scale', 'showall',
								'wmode', 'window',
								'devicefont', 'false',
								'id', 'scoreboard2',
								'bgcolor', '#000000',
								'name', 'scoreboard',
								'menu', 'true',
								'allowFullScreen', 'false',
								'allowScriptAccess','sameDomain',
								'movie', 'scoreboard2',
								'salign', '',
								'FlashVars', '<?= $flashVar ?>'
								); //end AC code
						</script>
						<noscript>
							<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="900" height="1000" id="scoreboard2" align="middle">
							<param name="allowScriptAccess" value="sameDomain" />
							<param name="allowFullScreen" value="false" />
							<param name="movie" value="scoreboard2.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" />	<embed src="scoreboard2.swf" quality="high" bgcolor="#000000" width="900" height="1000" name="scoreboard" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
							</object>
						</noscript>
						
						<iframe frameborder="0" style="width:1000px;height:350px;frameborder:0;border:0px;" src="http://96.53.92.6:8080/appointments/indexEmbed.php?e=runtoglorydecchallenge"></iframe>
						
						<br>
						<center>
							<table cellspacing="0" cellpadding="0" class="headerTbl">
								<tr>
									<td style="padding:5px 0px;font-weight:bold;vertical-align:bottom;color:white">
										&nbsp;
										<a href="index.php">Salesperson Board</a>		
										&nbsp;|&nbsp;
										<a href="sales.php">Sales Log</a>			
										<!--
										&nbsp;|&nbsp;
										<a href="http://96.53.92.6:8080/appointments/index.php?e=northpittsburghchallenge" target="_blank">Appointments Board</a>
										&nbsp;|&nbsp;
										<a href="map.html" target="_blank">Sales Map</a>
										-->
										&nbsp;|&nbsp;
										<a href="../halloffame.php" target="_blank">Hall Of Fame</a>
										
									</td>
								</tr>
							</table>
						</center>
						</div>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<table cellspacing="0" cellpadding="0" style="width:100%">	
	<tr>
		<td style="font-weight:bold">Total: <?= $totalSales ?> sales</td>
	</tr>
</table>
<table cellspacing="0" cellpadding="0" class="listTbl">	
	<tr>
		<th style="width:40%"><a href="?sort=salesperson">Salesperson <font style="font-weight:normal"><i>(Total: <?= count($salesArray) ?>)</i></font> <?= ($_SESSION['runtoglorydecchallenge']['sort'] == 'salesperson' ? $sortIcon : '') ?></a></th>
		<th style="width:15%"><a href="?sort=dealer">Dealership <?= ($_SESSION['runtoglorydecchallenge']['sort'] == 'dealer' ? $sortIcon : '') ?></a></th>
		<th style="width:15%"><a href="?sort=sales">Sales <?= ($_SESSION['runtoglorydecchallenge']['sort'] == 'sales' ? $sortIcon : '') ?></a></th>		
		<th style="width:15%"><a href="?sort=goal">Goal <font style="font-weight:normal"><i>(Total: <?= $totalGoals ?>)</i></font> <?= ($_SESSION['runtoglorydecchallenge']['sort'] == 'goal' ? $sortIcon : '') ?></a></th>		
		<th style="width:15%"><a href="?sort=pace">Pace <?= ($_SESSION['runtoglorydecchallenge']['sort'] == 'back' ? $sortIcon : '') ?></a></th>		
	</tr>
<?php
	foreach($salesArray as $salespersonID => $salespersonInfo)
	{
		if($salespersonInfo['info']['dealer'] == $dealerships[0]) $bgColor = '#660000';
		else if($salespersonInfo['info']['dealer'] == $dealerships[1]) $bgColor = '#CC3300';
		else if($salespersonInfo['info']['dealer'] == $dealerships[2]) $bgColor = '#000066';
		else if($salespersonInfo['info']['dealer'] == $dealerships[3]) $bgColor = '#335100';
		else if($salespersonInfo['info']['dealer'] == $dealerships[4]) $bgColor = '#000000';
		else if($salespersonInfo['info']['dealer'] == $dealerships[5]) $bgColor = '#444444';
		
		if($salespersonInfo['info']['dealer'] == $dealerships[0]) $bgColor = '#000000';
		else if($salespersonInfo['info']['dealer'] == $dealerships[1]) $bgColor = '#444444';
		else if($salespersonInfo['info']['dealer'] == $dealerships[2]) $bgColor = '#333333';
		else if($salespersonInfo['info']['dealer'] == $dealerships[3]) $bgColor = '#000000';
		else if($salespersonInfo['info']['dealer'] == $dealerships[4]) $bgColor = '#444444';
		else if($salespersonInfo['info']['dealer'] == $dealerships[5]) $bgColor = '#333333';
		else if($salespersonInfo['info']['dealer'] == $dealerships[6]) $bgColor = '#000000';
		else if($salespersonInfo['info']['dealer'] == $dealerships[7]) $bgColor = '#444444';
		else if($salespersonInfo['info']['dealer'] == $dealerships[8]) $bgColor = '#333333';
		else if($salespersonInfo['info']['dealer'] == $dealerships[9]) $bgColor = '#000000';
		else if($salespersonInfo['info']['dealer'] == $dealerships[10]) $bgColor = '#444444';
		else if($salespersonInfo['info']['dealer'] == $dealerships[11]) $bgColor = '#333333';
		
		
		if($currentDealer == "")
		{
			$isAlternate = false;
			$currentDealer = $salespersonInfo['info']['dealer'];
		}
		else if($currentDealer != $salespersonInfo['info']['dealer'])
		{
			$isAlternate = !$isAlternate;
			$currentDealer = $salespersonInfo['info']['dealer'];
		}
		if($isAlternate) $bgColor = "#555555";
		else $bgColor = "#000000";
		
?>
	<tr style="background-color:<?= $bgColor ?>">
		<td><?= $salespersonInfo['info']['name'] ?></td>
		<td><?= $salespersonInfo['info']['dealer'] ?></td>
		<td><?= $salespersonInfo['count'] ?></td>
		<td><?= $salespersonInfo['info']['goal'] ?></td>
		<td><?= $salespersonInfo['pace'] ?></td>
	</tr>
<?php
	}
?>	
	<tr>
		<th>Salesperson <font style="font-weight:normal"><i>(Total: <?= count($salesArray) ?>)</i></font></th>
		<th></th>
		<th></th>
		<th>Goal <font style="font-weight:normal"><i>(Total: <?= $totalGoals ?>)</i></font></th>
		<th></th>
	</tr>
</table>
<?php
	include_once('footer.php');
?>