<?php
	ob_start();
	session_start();
    
    include("dbConnection.php");
    include("admin.php");

    //Declaring Variables
	$success = "";
	$failure = "";
	 $userId;
	 $message = "";
	
	$NA = "<font color = 'red'>Not Available</font>";

	//Retrieving Session Variable
	if(isset($_SESSION["adminId"]))
	{
		$adminId = $_SESSION["adminId"];
		//echo $adminId;
	}
	else
	{
		header('Location:index.php?message=Unauthorized%20Access%20Prohobited');
	}
	//Retrieving Query String Variable
	if(isset($_REQUEST["success"]))
	{
		$success = $_REQUEST["success"];
	}
	
	if(isset($_REQUEST["failure"]))
	{
		$failure = $_REQUEST["failure"];
	}
	
	if(isset($_REQUEST["searchFrom"]))
	{

		$searchFrom = $_REQUEST["searchFrom"];
		//echo date_format($searchFrom, 'm/d/y');
		
	}
	else
	{
		$searchFrom = "";

		//echo $searchFrom . "<br/>";
	}

	//Creating 'dbConnection' Object
	$dbObj = new dbConnection();
	$con = $dbObj->getConnection();
	//echo $con . "<br/>";
	
	if($con)
	{
		//echo "MySQL Server Connected<br/>";
		$dbResult = $dbObj->selectDatabase();
		if($dbResult)
		{
			//echo "Database Selected<br/>";
			
			//Creating Admin Object
			
			$adminObj = new admin();
			$recordSet = $adminObj->getDayReports($searchFrom,$con);
			$totalRecords = mysql_num_rows($recordSet);
		}
		else
		{
			echo mysql_errno() . " : " . mysql_error();
		}
	}
	else
	{
		echo mysql_errno() . " : " . mysql_error();
	}
	


?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="keywords"
	content="admin, dashboard, bootstrap, template, flat, modern, theme, responsive, fluid, retina, backend, html5, css, css3">
<meta name="description" content="">
<meta name="author" content="ThemeBucket">
<link rel="shortcut icon" href="#" type="image/png">

<title> Alerts</title>

<!--pickers css-->

  <link rel="stylesheet" type="text/css" href="js/bootstrap-datepicker/css/datepicker-custom.css" /> 

  <link rel="stylesheet" type="text/css" href="js/bootstrap-daterangepicker/daterangepicker-bs3.css" />

  <!--dynamic table-->
  <link href="js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
  <link href="js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
  <link rel="stylesheet" href="js/data-tables/DT_bootstrap.css" />

<!--common-->
<link href="css/style.css" rel="stylesheet">
<link href="css/style-responsive.css" rel="stylesheet">




<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
  <script src="js/respond.min.js"></script>
  <![endif]-->
 
 



</head>

<body class="sticky-header">

	<section>
		<!-- left side start-->
		<div class="left-side sticky-left-side">

			<!--logo and iconic logo start-->
			<?php include("include/add-logo.php"); ?>
			<!--logo and iconic logo end-->

			<div class="left-side-inner">

				<!-- visible to small devices only -->
				<div class="visible-xs hidden-sm hidden-md hidden-lg">
					<div class="media logged-user">
						
					</div>

					<h5 class="left-nav-title">Account Information</h5>
					<ul class="nav nav-pills nav-stacked custom-nav">
						<li><a href="EditProfile.php"><i class="fa fa-user"></i> <span>Profile</span></a></li>
						<li><a href="changePassword.php"><i class="fa fa-cog"></i> <span>Settings</span></a></li>
						<li><a href="SignOut.php"><i class="fa fa-sign-out"></i> <span>SignOut</span></a></li>
					</ul>
				</div>

				<?php
					include("include/sideNav.php");
				?>

				

			</div>
		</div>
		<!-- left side end-->

		<!-- main content start-->
		
		<div class="main-content">

			<!-- header section start-->
			<div class="header-section">

				<!--toggle button start-->
				<a class="toggle-btn"><i class="fa fa-bars"></i></a>
				<!--toggle button end-->

				<!--search start-->
				<!-- <form class="searchform" action="index.html" method="post">
					<input type="text" class="form-control" name="keyword"
						placeholder="Search here..." />
				</form> -->
				<!--search end-->

				<!--notification menu start -->
				<div class="menu-right">
					<ul class="notification-menu">
						
						
						
							
						<li><a href="#" class="btn btn-default dropdown-toggle"
							data-toggle="dropdown">  Admin <span
								class="caret"></span>
						</a>
							<ul class="dropdown-menu dropdown-menu-usermenu pull-right">
								<li><a href="EditProfile.php"><i class="fa fa-user"></i> Profile</a></li>
								<li><a href="changePassword.php"><i class="fa fa-cog"></i> Settings</a></li>
								<li><a href="SignOut.php" data-toggle="model" data-target="#mymodel"><i
										class="fa fa-sign-out"></i> Log Out</a></li>
							</ul>
						</li>

					</ul>
				</div>
				<!--notification menu end -->

			</div>
			<!-- header section end-->

			
			<div class="container">

				<div class="modal fade" id="mymodal" role="dialog">
					<form action="go" method="post" id="mymodel">
						<div class="modal-dialog">

							<!-- Modal content-->
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal">&times;</button>
									<h4 class="modal-title">Logout Confirmation</h4>
								</div>
								<div class="modal-body">
									<p>Are you sure want to Sign out!</p>
								</div>
								<div class="modal-footer">
									<button autofocus="autofocus" type="submit"
										class="btn btn-default ">Yes</button>
									<button type="button" class="btn btn-default"
										data-dismiss="modal">No</button>
								</div>
							</div>

						</div>
					</form>
				</div>

			</div>

			 <!-- logout popup ends-->
			 
			<div class="wrapper">
            	<div class="row mt">
        			<div class="col-lg-12">
						<?php
						if($success != "")
						{
							echo "<div class='alert alert-success alert-dismissable'>
						  <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
						  <strong>SUCESS!&nbsp;&nbsp;&nbsp; </strong> $success</div>";
						}
						if($failure != "")
						{
							echo "<div class='alert alert-danger alert-dismissable'>
						  <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
						  <strong>Warning!&nbsp;&nbsp;&nbsp; </strong>$failure</div>";
						}
						?>
        				<section class="panel" style="color:#F56F1F;" >
				            <header class="panel-heading" style="background-color:#353F4F;  border-radius:8px;color: white;">
				                Alerts Reports
				            </header>
            
							<h6 style = "color:red;" id = "errorMessage"></h6>
							<form>
				     
			                <div class="form-group">
		                    	<label class="col-sm-3 col-sm-3 control-label ">Select Date<span style="color:red">*</span></label>
		                    	<div class="col-sm-9">
						      		<input type="text" class="form-control" name="searchFrom" id="datePicker" placeholder="Select Date">
						      		<span id="doberror" style="color:red;font-family:Trebuchet MS;font-size:14px;"></span>
						      	</div>
						     </div>
							<div class="form-group">

							   <div class="col-sm-9">

								<input type="submit" class="btn btn-primary"  value="Go" onclick ="search();"/>

							   </div>

							</div>
                			</form>          
        				</section>
        			</div>
        		</div>
        	</div>

        	<?php
									//echo $totalRecords;
									//$totalRecords =0;
									if($totalRecords > 0)
									{
								?><hr>
      		<div class = "panel panel-primary">
				
				<div class = "panel-body">													
					<div class="table-responsive">
						<div class="adv-table">
        					<table  class="display table table-bordered table-striped" id="dynamic-table">
								
								<thead>
									<tr>
										<th><span style="color:green;"> Alerts Id</span></th>
										<th><span style="color:green;">Main Title</span></th>
										<th><span style="color:green;">Sub Title</span></th>
										<th><span style="color:green;">Sub-Main Title</span></th>
										
										<th><span style="color:green;">Facebook</span></th>
										
										
										<th><span style="color:green;">Update</span></th>
										<th><span style="color:green;">Delete</span></th>
									</tr>									
								</thead>
								<tbody>
														
									<?php 
									
									while($row = mysql_fetch_array($recordSet))
									{
										$add_alerts_id = $row["add_alerts_id"];
										$main_title = $row["main_title"];
										$sub_title = $row["sub_title"];
										$sub_main_title = $row["sub_main_title"];	
										$description = $row["description"];
										$facebook = $row["facebook"];
										$google_plus = $row["google_plus"];
										$twitter = $row["twitter"];
										$statusImage = $adminObj->getStatusImage($status);

										
										
										echo "<tr>";
											
											echo "<td>$add_alerts_id</td>";
											$str = convert_uuencode($add_alerts_id);
											//echo $str."<br>";
											echo "<td><a href = 'viewAlertDetails.php?add_alerts_id=".$str."'>$main_title</a></td>";
											
											echo "<td>$sub_title</td>";
											
												echo "<td>$sub_main_title</td>";
											
											
												
											
												
												echo "<td>$facebook</td>";
												
												
											
											
												echo "<td><a href = 'editAlerts.php?add_alerts_id=".$add_alerts_id."' class ='btn btn-success'>EDIT</a></td>";
											
											echo "<td><a href = 'deleteAlerts.php?add_alerts_id=".$str."' class ='btn btn-danger'>DELETE</a></td>";
										echo "</tr>";
									}
									?>
								</tbody>
								<tfoot>
        							<tr>
            							<th><span style="color:green;"> Alerts Id</span></th>
										<th><span style="color:green;">Main Title</span></th>
										<th><span style="color:green;">Sub Title</span></th>
										<th><span style="color:green;">Sub-Main Title</span></th>
										
										<th><span style="color:green;">Facebook</span></th>
										
										
										<th><span style="color:green;">Update</span></th>
										<th><span style="color:green;">Delete</span></th>
						        	</tr>
						        </tfoot>
									
							</table>
						</div>															
					</div>
				</div>	
			</div>
        
        <?php
										}
										else{
											echo "<center><b>Sorry, Records Not Found</b></center>";
										}
									
										?>

			                    

			<!--footer section start-->
			<!-- <footer> <?php echo date("Y");?> &copy; Avyayasolutions </footer> -->
			
			<!--footer section end-->

     
		</div>



		<!-- main content end-->
	</section>

	<!-- Placed js at the end of the document so the pages load faster -->
	<script src="js/jquery-1.10.2.min.js"></script>
	<script src="js/jquery-ui-1.9.2.custom.min.js"></script>
	<script src="js/jquery-migrate-1.2.1.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/modernizr.min.js"></script>
	<script src="js/jquery.nicescroll.js"></script>

	<!--pickers plugins-->

	<script type="text/javascript" src="js/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

	<script type="text/javascript" src="js/bootstrap-daterangepicker/moment.min.js"></script>

	<script type="text/javascript" src="js/bootstrap-daterangepicker/daterangepicker.js"></script>

	<!--pickers initialization-->

	<script src="js/pickers-init.js"></script>

	<!--dynamic table-->
	<script type="text/javascript" language="javascript" src="js/advanced-datatable/js/jquery.dataTables.js"></script>
	<script type="text/javascript" src="js/data-tables/DT_bootstrap.js"></script>
	<!--dynamic table initialization -->
	<script src="js/dynamic_table_init.js"></script>

	<!--common scripts for all pages-->
	<script src="js/scripts.js"></script>
	

<script type="text/javascript">
      $(document).ready(function(){
        $('#datePicker').datepicker({
          
          //appendText: "(yyyy-mm-dd)",
          dateFormat: "yy-mm-dd",
          autoSize: true,
          //showOn: "both",
          showWeek: true,
          //buttonImageOnly: true,
          //buttonText:'calandar',
          //buttonImage: "images/datepicker.png",
          altField: "#actualDate",
          altFormat: "yy-mm-dd",
          changeMonth: true,
          changeYear: true,
          yearRange: "1960:2017",
          //minDate:new Date(2001,1,1),
          //maxDate:new Date(2017,11,31),
          //minDate: -20, 
          //maxDate: "+1M +10D",
          //showButtonPanel: true,
          //currentText: "Now",
          //closeText: "Close"
        });
      });
    </script>

</body>
</html>
