<?php
// INCLUDE HEADER IN PAGE
include('other_header.php');
// GET CURRENT DATE AND TIME
$date = date('Y-m-d H:i:s');
if(isset($_POST['success'])) {
	if($_POST['success'] == 'loggedin') {
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong>Well done!</strong> Successfully logged in.
	</div>
	<?php
	}
}
	//ADVERTISER
	$queryCAMPAIGNS = "SELECT COUNT(id) AS numrows FROM ads WHERE owner='$session_username'";
	$resultCAMPAIGNS  = mysql_query($queryCAMPAIGNS) or die('Error, query failed');
	$rowCAMPAIGNS     = mysql_fetch_array($resultCAMPAIGNS, MYSQL_ASSOC);
	$numCAMPAIGNS = $rowCAMPAIGNS['numrows'];
	
	$graphCAMPAIGN = mysql_fetch_array(mysql_query("SELECT * FROM advertisers WHERE username='$session_username'"));
	$graphCAMPAIGNS[1] = $graphCAMPAIGN['date1'];
	$graphCAMPAIGNS[2] = $graphCAMPAIGN['date2'];
	$graphCAMPAIGNS[3] = $graphCAMPAIGN['date3'];
	$graphCAMPAIGNS[4] = $graphCAMPAIGN['date4'];
	$graphCAMPAIGNS[5] = $graphCAMPAIGN['date5'];
	$graphCAMPAIGNS[6] = $graphCAMPAIGN['date6'];
	$graphCAMPAIGNS[7] = $graphCAMPAIGN['date7'];
	$weirdooCAMPAIGNS = $graphCAMPAIGNS[1] + $graphCAMPAIGNS[2] + $graphCAMPAIGNS[3] + $graphCAMPAIGNS[4] + $graphCAMPAIGNS[5] + $graphCAMPAIGNS[6] + $graphCAMPAIGNS[7];
	// PUBLISHER
	$queryLINKS = "SELECT COUNT(id) AS numrows FROM items WHERE username='$session_username'";
	$resultLINKS  = mysql_query($queryLINKS) or die('Error, query failed');
	$rowLINKS     = mysql_fetch_array($resultLINKS, MYSQL_ASSOC);
	$numLINKS = $rowLINKS['numrows'];
			
	$graphLINK = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE username='$session_username'"));
	$graphLINKS[1] = $graphLINK['date1'];
	$graphLINKS[2] = $graphLINK['date2'];
	$graphLINKS[3] = $graphLINK['date3'];
	$graphLINKS[4] = $graphLINK['date4'];
	$graphLINKS[5] = $graphLINK['date5'];
	$graphLINKS[6] = $graphLINK['date6'];
	$graphLINKS[7] = $graphLINK['date7'];
	$weirdooLINKS = $graphLINKS[1] + $graphLINKS[2] + $graphLINKS[3] + $graphLINKS[4] + $graphLINKS[5] + $graphLINKS[6] + $graphLINKS[7];
?>
  <div class="container">
    <div class="text-center">
      <h1><?php echo $title; ?>
      	<small>/
      			<?php
						$accounttypenow = $_SESSION['acctype'];
						if($accounttypenow == 0){//Publisher
					?>
							Active is: Publisher Account
					<?php
						}
						if($accounttypenow == 1){//Advertiser
					?>
							Active is: Advertiser Account
					<?php
						}
					?>
			</small>
		</h1>
 	 </div>
		</br>
	<div class="text-center">
      <h1><small>Publisher's account</small></h1>
 	</div>
		<div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">
              <?php echo $a002; ?></h3>
            </div>
            <div class="panel-body">
            	<?php echo $numLINKS ?>
            </div>
          </div>
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title"><?php echo $a067; ?></h3>
            </div>
            <div class="panel-body">
              $ <?php echo"{$seeP['balance']}"; ?>
            </div>
          </div>
        </div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title"><?php echo $a018; ?></h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeP['date7']}"; ?>
            </div>
          </div>
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title"><?php echo $a066; ?></h3>
            </div>
            <div class="panel-body">
              <?php echo $graphLINKS[7]; ?>
            </div>
          </div>
        </div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Yesterday</h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeP['date6']}"; ?>
            </div>
          </div>
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Last logged in IP</h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeP['lastip']}"; ?>
            </div>
          </div>
        </div>
        </br>
        </br>
   <div class="text-center">
      <h1><small>Advertiser's account</small></h1>
 	</div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">
              <?php echo $a052; ?></h3>
            </div>
            <div class="panel-body">
            	<?php echo $numCAMPAIGNS ?>
            </div>
          </div>
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title"><?php echo $a067; ?></h3>
            </div>
            <div class="panel-body">
              $ <?php echo"{$seeA['balance']}"; ?>
            </div>
          </div>
        </div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title"><?php echo $a018; ?></h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeA['date7']}"; ?>
            </div>
          </div>
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title"><?php echo $a066; ?></h3>
            </div>
            <div class="panel-body">
              <?php echo $graphCAMPAIGNS[7]; ?>
            </div>
          </div>
        </div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Yesterday</h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeA['date6']}"; ?>
            </div>
          </div>
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Last logged in IP</h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeA['lastip']}"; ?>
            </div>
          </div>
        </div>
    <div class="text-center">
      <h1><small>Other informations</small></h1>
 	</div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">
						Your country           
              </h3>
            </div>
            <div class="panel-body">
            	<?php echo"{$seeP['country']}"; ?>
            </div>
          </div>
        </div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Referred users</h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeP['totalrefs']}"; ?>
            </div>
          </div>
        </div>
        <div class="col-sm-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Referral earnings</h3>
            </div>
            <div class="panel-body">
              <?php echo"{$seeP['refearnings']}"; ?>
            </div>
          </div>
        </div>
</div>

<?php
include('other_footer.php');
?>
