MSV FM

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

<?php
	include_once('includes.php');
	include_once('mysqlUtils.php');
	session_start();
	
	$_GET['events'] = implode(',',$eventIDs);
	$salesArray = array();
	$caraSalesArray = array();
	$totalSales = 0;
	$totalGoals = 0;
	$totalPace = 0;
	$top = 0;	
	
	$event = mysql_fetch_assoc(mysql_query('SELECT eventID,numSalesman,saleStartDate FROM ps_dealerevents where eventID in (' . $_GET['events'] . ') ORDER BY eventID'));		
	$apptTbl = 'ps_appointments_' . date("my",strtotime($event['saleStartDate']));
	
	//WITH DEALER NAME///////////					
	$sql = 'SELECT * FROM
			  (SELECT eventID,challengeSalesrep,count(*) as salesCount FROM ' . $apptTbl . ' WHERE eventID in (' . $_GET['events'] . ') AND (sold1 is not null AND sold1 != "") group by challengeSalesrep,eventID) as t1
			RIGHT JOIN
			  (SELECT * FROM
			    (SELECT * FROM
			    	(SELECT dealerID,eventID FROM ps_dealerevents WHERE eventID in (' . $_GET['events'] . ')) as ttt1
			    INNER JOIN
			    	(SELECT dealerID,dealerName FROM ps_dealers) as ttt2
			    USING
			    	(dealerID)) as tt1
			  INNER JOIN
			    (SELECT * FROM ps_salesrep) as tt2
			  USING (dealerID)) as t2
			ON
			  (t1.challengeSalesrep = t2.name AND t1.eventID = t2.eventID)';
	//////////////////////////////
	
	$exportArray = array();
	
	for($i = 1;$i <=3;$i++)
	{
		$sql = 'SELECT * FROM
				  (SELECT eventID,challengeSalesrep,count(*) as salesCount FROM ' . $apptTbl . ' WHERE eventID in (' . $_GET['events'] . ') AND (sold' . $i . ' is not null AND sold' . $i . ' != "") group by challengeSalesrep,eventID) as t1
				RIGHT JOIN
				  (SELECT * FROM
				    (SELECT dealerID,eventID FROM ps_dealerevents WHERE eventID in (' . $_GET['events'] . ')) as tt1
				  INNER JOIN
				    (SELECT * FROM ps_salesrep) as tt2
				  USING (dealerID)) as t2
				ON
				  (t1.challengeSalesrep = t2.name AND t1.eventID = t2.eventID)';
		
		$results = mysql_query($sql);
		while($salesrep = mysql_fetch_assoc($results))
		{
			$exportArray[] = array('name' => $salesrep['name'],
								   'eventID' => $salesrep['eventID'],
								   'goal' => $salesrep['goal'],
								   'count' => $salesrep['salesCount'],
								   'salesrepID' => $salesrep['salesrepID']);
		}
	}

	$dataArray = $exportArray;
	
	foreach($dealerships as $dealer)
	{
		$t = $dealer.'Total';
		$$t = 0;
	}
	
	foreach($dataArray as $salesrep)
	{
		$salesArray[$salesrep['salesrepID']]['info'] = $salesrep;
		$salesArray[$salesrep['salesrepID']]['count'] = $salesArray[$salesrep['salesrepID']]['count'] + $salesrep['count'];
		$salesArray[$salesrep['salesrepID']]['pace'] = $salesArray[$salesrep['salesrepID']]['count'] - $salesrep['goal'];
		
		//$salesArray[$salesrep['salesrepID']] = $tempArray;
		$totalGoals += $salesrep['goal'];	
		$totalSales += $salesrep['count']; 	
		
		$t = $dealerEvents[$salesrep['eventID']] . 'Total';
		$$t += $salesrep['count'];
	}
	foreach($dealerships as $dealer)
	{
		$t = $dealer.'Total';
		$flashVar .=  $dealer . 'Sold=' . $$t . '&';
	}
	

////////////////////////////////
//REGULAR LOGIN/////////////////
////////////////////////////////
/*
	include_once('mysqlUtils.php');
	
	$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 urseprivatesalechallenge_salesperson');
	
	$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'];
	}
		
	$salesResults = mysql_query('SELECT salesman, count(*) as salesmanCount FROM urseprivatesalechallenge_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 . '&';
	}
	
	//$flashVar .=  'appointments=' . file_get_contents("http://96.53.92.6:8080/appointments/index.php?e=urseprivatesalechallenge&getTotal=") . '&';
	//$flashVar .=  'appointments=0&';
*/
	function salesSort($a,$b)
	{		
		if($a['info']['eventID'] == $b['info']['eventID']) return $a['count'] < $b['count'];
		return $a['info']['eventID'] < $b['info']['eventID'];
	}
	
	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['urseprivatesalechallenge']['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', '<?= $flashHeight ?>',
								'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="<?= $flashHeight ?>" 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="<?= $flashHeight ?>" 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:<?= $apptHeight ?>px;frameborder:0;border:0px;" src="../../appointments/indexEmbed.php?el=<?= implode(",",$eventIDs) ?>"></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="html.php">Non-Flash Version</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['urseprivatesalechallenge']['sort'] == 'salesperson' ? $sortIcon : '') ?></a></th>
		<th style="width:15%"><a href="?sort=dealer">Dealership <?= ($_SESSION['urseprivatesalechallenge']['sort'] == 'dealer' ? $sortIcon : '') ?></a></th>
		<th style="width:15%"><a href="?sort=sales">Sales <?= ($_SESSION['urseprivatesalechallenge']['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['urseprivatesalechallenge']['sort'] == 'goal' ? $sortIcon : '') ?></a></th>		
		<th style="width:15%"><a href="?sort=pace">Pace <?= ($_SESSION['urseprivatesalechallenge']['sort'] == 'back' ? $sortIcon : '') ?></a></th>		
	</tr>
<?php
	foreach($salesArray as $salespersonID => $salespersonInfo)
	{		
		if($currentDealer == "")
		{
			$isAlternate = false;
			$currentDealer = $salespersonInfo['info']['eventID'];
		}
		else if($currentDealer != $salespersonInfo['info']['eventID'])
		{
			$isAlternate = !$isAlternate;
			$currentDealer = $salespersonInfo['info']['eventID'];
		}
		if($isAlternate) $bgColor = "#555555";
		else $bgColor = "#000000";
?>
	<tr style="background-color:<?= $bgColor ?>">
		<td><?= $salespersonInfo['info']['name'] ?></td>
		<td><?= $dealerEvents[$salespersonInfo['info']['eventID']] ?></td>
		<td><?= number_format($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');
?>