<?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, '/');
	
	require 'includes/Url.php';
	require 'includes/Paging.php';	
	$objNotifications = new ParseQuery("notifications");
					
	$objNotifications->descending('createdAt');
	$result = $objNotifications->find();
	$objPaging = new Paging($result, 50);
	$rows = $objPaging->getRecords();
	$objPaging->url = $objPaging->url;
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<title>Manage Notifications</title>
	<?php include 'includes/head.php'; ?>
    <style>
    	.glyphicon-signal{
    		background-color: #f8e409;
    	}
    </style>
</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">
                         <h1 class="page-header">
                            Manage Notifications
							<a href="add-notification.php" class="btn btn-success pull-right">Create New notification</a>
                        </h1>
                        <div class="table-responsive">
                            <table id="listBeacons" class="table table-bordered table-hover table-striped">
                                <thead>
                                    <tr>
                                        <th>Notification</th>                                        
                                        <th>Action</th>										
                                    </tr>
                                  </thead>
                                    <tbody>
                                      <?php        								
                                      foreach($rows as $n){ 
                                      	$getObjectId = $n->getObjectId(); ?>
                                   			<tr>
                                   				<td><?php echo $n->get('text');?></td>                                   				
                                   				<td align="center" class="actionButtons" width="15%">
													                     <a data-toggle="tooltip" title="Delete" onclick="return confirm('Are you sure you want to delete this notificataion?');" href="delete-notification.php?uTp=<?php echo $getObjectId; ?>"><i class="glyphicon glyphicon-trash"></i></a>
													               </td>
                                   			</tr>
                                   <?php  } ?>
                                </tbody>
                            </table>
							             <?php  echo $objPaging->getPaging(); ?>
                        </div>
                    </div>
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

   <?php include 'includes/footer.php'; ?>
   
   <script>		
   </script>

</body>

</html>
