<?php
	require 'autoload.php';
	use Parse\ParseClient;
	use Parse\ParseObject;
	use Parse\ParseQuery;
	use Parse\ParseACL;
	use Parse\ParsePush;
	use Parse\ParseUser;
	use Parse\ParseInstallation;
	use Parse\ParseException;
	use Parse\ParseAnalytics;
	use Parse\ParseFile;
	use Parse\ParseCloud;
	
	include 'includes/func.php';
	include 'config.php';
	
	ParseClient::initialize($ApplicationID, $RestAPIKEY, $MasterKey);
	ParseClient::setServerURL($serverURLB4APP, '/');
?>
<?php
	if(!isset($_SESSION["username"])  && !isset($_SESSION["password"])){
		//header('Location: login.php');
	}
		
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<title>View Ad Campaign</title>
	<?php include 'includes/head.php'; ?>
</head>
<body>
    <div id="wrapper">
        <?php include 'includes/header.php';?>
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
					<div class="col-lg-12">
						<?php
							if(isset($_GET['uTp'])){
								$objID	=	$_GET['uTp'];
								$qury = new ParseQuery("ads");
								$result = $qury->get($objID);								
						?>	
                         <h1 class="page-header">
                            <?php echo '<b> Campaign Title: </b>'.$result->get("title").''; ?>
							<a href="manage-ad.php" class="btn btn-danger pull-right">Go Back</a>
                        </h1>
						<div class="row">
							<div class="col-md-12">
								<div class="panel panel-default">
									  <div class="panel-heading">Ad Campaign Details</div>
									  <div class="panel-body">
											<div class="row">
												<div class="col-md-12">
													<table class="table table-bordered table-hover">
														<tr>
															<td>Campaign Title</td>
															<td><?php echo $result->get("title"); ?></td>
														</tr>
														<tr>
															<td>Description</td>
															<td><?php echo $result->get("details"); ?></td>
														</tr>		
														
														<tr>
															<td>Start Date</td>
															<td><?php echo date('m/d Y H:i',strtotime($result->get("start_date"))); ?></td>
														</tr>
														<tr>
															<td>End Date</td>
															<td><?php echo date('m/d Y H:i',strtotime($result->get("end_date"))); ?></td>
														</tr>
														<tr>
															<td>Image</td>
															<td><?php 
															$pics = explode(',',$result->get('pic'));
                                    						$url = url();
                                    						foreach($pics as $i=>$pic){ ?>
																<img src="<?php echo  $url.'/uploads/'.$pic; ?>" height="200px" />
                                    						<?php } ?>
															</td>
														</tr>
																												
													</table>
												</div>
											</div>
									  </div>
									</div>
							</div>							
						</div>
						<?php } ?>
                    </div>
					
					
					
                </div>
                <!-- /.row -->
			</div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
   <?php include 'includes/footer.php'; ?>
    
</body>
</html>