
<?php header('location:../'); ?>

<?php
	session_start();
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Testimonials Admin | Media Age PR &copy;</title>

  <link rel="apple-touch-icon" sizes="180x180" href="../../images/img/logo1.png">
    <link rel="icon" type="image/png" href="../../images/img/logo1.png" sizes="32x32">
    <link rel="icon" type="image/png" href="../../images/img/logo1.png" sizes="16x16">


	<!--Boxicons-->
	<link href="boxicons/boxicon.min.css" rel="stylesheet">


	<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="datatable/dataTable.bootstrap.min.css">
	<style>
		

.top-btns {
  padding: 20px;
}


.bx {
	color: red;
}


/*Industry*/
.industry-section {
    margin-top: 30px;
}


.industry-section h3 {
    text-transform: uppercase;
    font-weight: bold;
    font-size: 14px;
    color: red;
    text-align: center;
}


.industry {
    width: 95%;
    margin-left: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    box-shadow: 0 0 4px 0 red;
}



.industry a{
  font-size: 20px;
	margin: 20px;
}


.industry a:nth-child(1) {
	color: red;
}


.industry a:nth-child(2) {
	color: red;
}


.industry h6{
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    text-align: center;
    color: red;
    margin-top: 10px;
}

.industry .id{
  margin: 5px;
  text-align: center;
  font-size: 12px;
  color: #FEFAFA;
  width: 25px;
  height: 25px;
  padding: 4px;
  border-radius: 50px;
  background: red;
  box-shadow: 1px 1px 2px 0 rgba(0, 0, 0, 0.2);
}


.industry img{
    width: 100px;
    height: 100px;
    object-fit: cover;
    object-position: top;
    border: 1px solid rgba(255, 0, 0, 0.4);
    border-radius: 100px;
    margin: 30px 10px 10px 10px;
}

.industry b {
  font-size: 10px;
	color: #e0f9fa;
  margin-left: 2px;
	padding: 5px 10px;
	border-radius: 30px;
	background: red;
}


.industry b:nth-child(1) {
	border-top-right-radius: 0;
	border-bottom-right-radius: 0;
}


.industry b:nth-child(2) {
	border-top-left-radius: 0;
	border-bottom-left-radius: 0;
}


.industry .price {
	font-size: 14px;
	text-align: center;
	color: black;
  padding: 10px;
	margin-top: 20px;
	margin-bottom: 20px;
}


/* If the screen size is 601px wide or more */
@media screen and (min-width: 601px) {


.industry {
    float: left;
    width: 32%;
    margin-left: 13px;
    margin-bottom: 20px;
}


.industry h6 {
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 10px;
}

 }


.edit-img img {
  width: 20%;
  border-radius: 100%;
  box-shadow: 0 0 0 1px red;
}


.approve-links {
  margin: 30px 20px 0px 20px;
  color: white;
  border: none;
  border-radius: 5px;
  padding: 10px 20px;
  background: gray;
}

.approve-links a {
  color: white !important;
}




	</style>
</head>
<body>

	<div align="center">
	<img src="../../images/img/logo5.png" class="page-header text-center" width="300px">
	</div>
	
			<?php
				if(isset($_SESSION['error'])){
					echo
					"
					<div class='alert alert-danger text-center'>
						<button class='close'>&times;</button>
						".$_SESSION['error']."
					</div>
					";
					unset($_SESSION['error']);
				}
				if(isset($_SESSION['success'])){
					echo
					"
					<div class='alert alert-success text-center'>
						<button class='close'>&times;</button>
						".$_SESSION['success']."
					</div>
					";
					unset($_SESSION['success']);
				}
			?>
			

			<div class="top-btns">
				<a href="#addnew" data-toggle="modal" class="btn btn-primary" style="background: red;border: none;"><span class="glyphicon glyphicon-plus"></span> New</a>
				<a href="print_pdf.php" class="btn btn-success pull-right" style="background: red;border: none;"><span class="glyphicon glyphicon-print"></span> PDF</a>
			</div>

			<?php
              include_once('db/connection.php');

              $sql = "SELECT * FROM testimonials";

              //use for MySQLi-OOP
              $query = $conn->query($sql);
              while($row = $query->fetch_assoc()){
            

     echo "<section class='industry-section'>";

        echo "<div class='industry'>";

echo "<div align='center'>";
			if ($row['image']) { echo "<img src='images/".$row['image']."'>";} 
			elseif ($row['image']=="") { echo "<img src='images/default.png'>";}	
echo "</div>";			

             echo "<h3 class='name'>".$row['name']."</h3>";

             echo "<h3>".$row['position']."</h3>";

             echo "<div class='price'>".$row['testimonial']."</div>";

             echo "<div class='price'>".date("M jS, h:i A", strtotime($row['date']))."</div>";

             echo "<hr>";

             echo "<div align='center'>";
    		echo "<a href='#edit_".$row['id']."' data-toggle='modal'><i class='bx-fw bx bx-edit'></i></a> | <a href='#delete_".$row['id']."' data-toggle='modal'><i class='bx-fw bx bx-trash'></i></a>";

        echo "<div class='approve-links'>";

        if ($row['approve']=="") { echo "<a href=\"approve.php?id=$row[id]\" onClick=\"return confirm('Are you sure you want to Approve this testimonial?')\">Approve</a> | <a href=\"decline.php?id=$row[id]\" onClick=\"return confirm('Are you sure you want to decline this testimonial?')\">Decline</a>"; }

          elseif ($row['approve']==1) { echo "<a>Approved</a> | <a href=\"decline.php?id=$row[id]\" onClick=\"return confirm('Are you sure you want to decline this testimonial?')\">Decline</a>"; } 

          elseif ($row['approve']==2) { echo "<a href=\"approve.php?id=$row[id]\" onClick=\"return confirm('Are you sure you want to Approve this testimonial?')\">Approve</a> | <a>Declined</a>"; }
        echo "</div>";

    		 echo "</div>";	

	    echo "<br>";	

 		echo "</div>";
     echo "</section>";

     include('edit_delete_modal.php');

     }
	?>
     <!--End Industry-->


<?php include('add_modal.php') ?>

<script src="jquery/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="datatable/jquery.dataTables.min.js"></script>
<script src="datatable/dataTable.bootstrap.min.js"></script>
<!-- generate datatable on our table -->
<script>
$(document).ready(function(){
	//inialize datatable
    $('#myTable').DataTable();

    //hide alert
    $(document).on('click', '.close', function(){
    	$('.alert').hide();
    })
});
</script>
</body>
</html>