MSV FM

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

<?php
	session_start();
	
	if(isset($_GET['sort']))
	{
		if($_SESSION['blackfridaychallenge']['sort'] == $_GET['sort']) $_SESSION['blackfridaychallenge']['sortASC'] = !$_SESSION['blackfridaychallenge']['sortASC'];
		else 
		{
			if(in_array($_GET['sort'],array('salesperson'))) $_SESSION['blackfridaychallenge']['sortASC'] = false;
			else $_SESSION['blackfridaychallenge']['sortASC'] = true;
		}
		
		
		$_SESSION['blackfridaychallenge']['sort'] = $_GET['sort'];
		header("location: index.php");
		exit;
	}
	
	if(!isset($_SESSION['blackfridaychallenge']['sort'])) $_SESSION['blackfridaychallenge']['sort'] = 'sales';
	if(!isset($_SESSION['blackfridaychallenge']['sortASC'])) $_SESSION['blackfridaychallenge']['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 blackfridaychallenge_salesperson (name) values ("' . $names2[$key] . '")';
		
		$fl = explode(" ",$name);
		$sql2 = 'INSERT INTO blackfridaychallenge_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 blackfridaychallenge_salesperson');
	$salesArray = array();
	$totalSales = 0;
	$totalGoals = 0;
	$totalPace = 0;
	$top = 0;
	
	$dealerships = array('parkway','orangeville','kawartha','renfrew','scarsview','hanover','niagara','dixie','erin','village','woodbine','unique','fairview','hunt','bluemountain','toronto','downsview','centennial','aurora','maciver');
	$flashVar = "";
	foreach($dealerships as $dealer)
	{
		$t = $dealer.'Total';
		$$t = 0;
	}
	/*
	$ottawaTotal = 0;
	$orleansTotal = 0;
	$dilawriTotal = 0;
	$metroTotal = 0;
	$capitalTotal = 0;
	$southbankTotal = 0;
	*/
	while($salesperson = mysql_fetch_assoc($salespersonResults))
	{
		$salesArray[$salesperson['salespersonID']]['info'] = $salesperson;
		$salesArray[$salesperson['salespersonID']]['count'] = 0;
		$totalGoals += $salesperson['goal'];
	}
		
	$salesResults = mysql_query('SELECT salesman, count(*) as salesmanCount FROM blackfridaychallenge_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'];
		}
		/*
		if($info['info']['dealer'] == 'ottawa') $ottawaTotal += $info['count'];
		if($info['info']['dealer'] == 'orleans') $orleansTotal += $info['count'];	
		if($info['info']['dealer'] == 'dilawri') $dilawriTotal += $info['count'];		
		if($info['info']['dealer'] == 'metro') $metroTotal += $info['count'];		
		if($info['info']['dealer'] == 'capital') $capitalTotal += $info['count'];		
		if($info['info']['dealer'] == 'southbank') $southbankTotal += $info['count'];	
		*/
	}
	
	foreach($dealerships as $dealer)
	{
		$t = $dealer.'Total';
		$flashVar .=  $dealer . 'Sold=' . $$t . '&';
	}
	
	function salesSort($a,$b)
	{		
		if($_SESSION['blackfridaychallenge']['sortASC'])
		{
			if($_SESSION['blackfridaychallenge']['sort'] == 'salesperson') return $a['info']['name'] < $b['info']['name'];
			else if($_SESSION['blackfridaychallenge']['sort'] == 'dealer')
			{
				if($a['info']['dealer'] == $b['info']['dealer']) return $a['count'] < $b['count'];
				return $a['info']['dealer'] < $b['info']['dealer'];
			}
			else if($_SESSION['blackfridaychallenge']['sort'] == 'goal') return $a['info']['goal'] < $b['info']['goal'];
			else if($_SESSION['blackfridaychallenge']['sort'] == 'sales') return $a['count'] < $b['count'];
			else return $a['pace'] < $b['pace'];
		}
		else
		{
			if($_SESSION['blackfridaychallenge']['sort'] == 'salesperson') return $a['info']['name'] > $b['info']['name'];
			else if($_SESSION['blackfridaychallenge']['sort'] == 'dealer')
			{
				if($a['info']['dealer'] == $b['info']['dealer']) return $a['count'] > $b['count'];
				return $a['info']['dealer'] > $b['info']['dealer'];
			}
			else if($_SESSION['blackfridaychallenge']['sort'] == 'goal') return $a['info']['goal'] > $b['info']['goal'];
			else if($_SESSION['blackfridaychallenge']['sort'] == 'sales') return $a['count'] > $b['count'];
			else return $a['pace'] > $b['pace'];
		}lse 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['blackfridaychallenge']['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>
						<!-- HTML VERSION -->
						<table cellspacing="0" cellpadding="0" style="width:800px; border:3px solid white">
							<tr>
								<td style="padding:20px">
									<center>
										<table cellspacing="0" cellpadding="0">
											<tr>
												<td style="font-size:16pt;color:white;text-align:center">
													<center>
													TOTAL SALES
													<br>													
													<div style="font-size:28pt;color:yellow;width:160px; padding:5px;border:2px solid white;text-align:center;vertical-align:middle">
		<?php	
			$vSoldTotal = 0;	
			foreach($dealerships as $dealer)
			{
				$t = $dealer.'Total';
				$vSoldTotal +=  $$t;
			}
		?>														<?= $vSoldTotal ?>
													</div>
													</center>
												</td>
											</tr>
										</table>
										<br><br>
										<table cellspacing="0" cellpadding="0">
											<tr>
		<?php	
			$vSoldTotal = 0;	
			foreach($dealerships as $dealer)
			{
				$t = $dealer.'Total';
				?>
												<td style="padding:15px;font-size:16pt;color:white;text-align:center">
													<center>
													<?= $dealer ?>
													<br>													
													<div style="font-size:28pt;color:yellow;padding:5px;border:2px solid white;text-align:center;vertical-align:middle">
														<?= $$t?>
													</div>
													</center>
												</td>
				<?php
			}
		?>									
											</tr>
										</table>
									</center>
								</td>
							</tr>
						</table>

<!-- HTML VERSION -->
							<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=blackfridaychallenge" target="_blank">Appointments Board</a>
										<!--&nbsp;|&nbsp;
										<a href="map.html" target="_blank">Sales Map</a>-->
									</td>
								</tr>
							</table>
						</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>
<div style="height:<?= ($perPage * 20) +25 ?>px">
<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['blackfridaychallenge']['sort'] == 'salesperson' ? $sortIcon : '') ?></a></th>
		<th style="width:15%"><a href="?sort=dealer">Dealership <?= ($_SESSION['blackfridaychallenge']['sort'] == 'dealer' ? $sortIcon : '') ?></a></th>
		<th style="width:15%"><a href="?sort=sales">Sales <?= ($_SESSION['blackfridaychallenge']['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['blackfridaychallenge']['sort'] == 'goal' ? $sortIcon : '') ?></a></th>		
		<th style="width:15%"><a href="?sort=pace">Pace <?= ($_SESSION['blackfridaychallenge']['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>
</div>
<?php
	include_once('footer.php');
?>