<?php
	//connection
	$host="localhost";
	$user="skytrees_search";
	$password="Skytree_searching";
	$database="skytrees_searching";
	
	$conn=mysqli_connect($host,$user,$password);
	$db=mysqli_select_db($conn,$database);
	//end of connection
	
	//session registered
	session_start();
	//end of session registered	
	
	//check session	
	if (!isset($_SESSION["person_id"])) {		
		header("Location:http:/internal/datamining/login.php");			
	}
	//end of check session	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Skytree Datamining - Dashboard</title>
<style type="text/css">
<!--
body {
	font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
	background: #42413C;
	margin: 0;
	padding: 0;
	color: #000;
}

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { 
	padding: 0;
	margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
	margin-top: 0;	 
	padding-right: 15px;
	padding-left: 15px; 
}
a img { 
	border: none;
}

a:link {
	color: #42413C;
	text-decoration: underline; 
}
a:visited {
	color: #6E6C64;
	text-decoration: underline;
}
a:hover, a:active, a:focus { 
	text-decoration: none;
}

.container {
	width: 90%;
	background: #FFF;
	margin: 0 auto; 
}

.header {
	background: #ADB96E;
}

.sidebar1 {
	float: left;
	width: 180px;
	background: #EADCAE;
	padding-bottom: 10px;
}

.content {
	margin-left:10px;
	margin-rigth:10px;
	padding: 10px 0;
	width: 80%;
	float: left;
}

.content ul, .content ol { 
	padding: 0 15px 15px 40px; 
}

ul.nav {
	list-style: none; 
	border-top: 1px solid #666; 
	margin-bottom: 15px; 
}
ul.nav li {
	border-bottom: 1px solid #666; 
}
ul.nav a, ul.nav a:visited { 
	padding: 5px 5px 5px 15px;
	display: block; 
	width: 160px;  
	text-decoration: none;
	background: #C6D580;
}
ul.nav a:hover, ul.nav a:active, ul.nav a:focus { 
	background: #ADB96E;
	color: #FFF;
}

.footer {
	padding: 10px 0;
	background: #CCC49F;
	position: relative;
	clear: both; 
}

.fltrt {  
	float: right;
	margin-left: 8px;
}
.fltlft { 
	float: left;
	margin-right: 8px;
}
.clearfloat { 
	clear:both;
	height:0;
	font-size: 1px;
	line-height: 0px;
}
-->
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="script.js"></script>
<script>
	$(document).ready(function(){
		$("#txt_submit").click(function(){
			var txt_search = $("#txt_search").val();
			var txt_type = $("#txt_type").val();
			var txt_count = $("#txt_count").val();
			var txt_date = $("#txt_date").val();
			
			var dataString = 'txt_search='+ txt_search + '&txt_type='+ txt_type + '&txt_count='+ txt_count + '&txt_date='+ txt_date;
			
			if(txt_search==''){
				alert("Please Fill All Fields");
			}else{
					$.ajax({
					type: "POST",
					url: "/internal/datamining/test7.php",
					data: dataString,
					cache: false,
					success: function(result){
						$("#hasil_cari").html(result);
					}
				});
			}
		return false;
		});
	});
</script>

<script>
	$(document).ready(function(){
		$("#txt_add_tag").click(function(){
			var txt_search = $("#txt_search").val();
			
			var dataString = 'txt_search='+ txt_search;
			
			if(txt_search==''){
				alert("Please Fill Search Tag");
			}else{
					$.ajax({
					type: "POST",
					url: "/internal/datamining/save_tag.php",
					data: dataString,
					cache: false,
					success: function(result){
						$("#save_tag").html(result);
					}
				});
			}
		return false;
		});
	});
</script>

<script type="text/javascript">
	var count = 5;
	function hitPhpScript() {
		var xmlhttp;
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("link").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","/internal/datamining/tes.php",true);
		xmlhttp.send();
		startCountdown();
	}
	
	function startCountdown() {
		count = 5;
		doCountdown();
	}
	
	function doCountdown() {
		count--;	
		if (count > 0) {
			//document.getElementById("countdown_label").innerHTML = count + " seconds left to reload the page automatically";
			setTimeout("doCountdown()", 1000);
		} else {
			hitPhpScript();
		}
	}
</script>

<script type="text/javascript">
	var count = 5;
	function popular() {
		var xmlhttp;
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("popular").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","/internal/datamining/test19.php",true);
		xmlhttp.send();
		startCountdown2();
	}
	
	function startCountdown2() {
		count = 5;
		doCountdown2();
	}
	
	function doCountdown2() {
		count--;	
		if (count > 0) {
			document.getElementById("countdown_label2").innerHTML = count + " seconds left to reload the popular data automatically";
			setTimeout("doCountdown2()", 1000);
		} else {
			popular();
		}
	}
</script>

<script>
function showhide(id){ 
	if (document.getElementById){ 
		obj = document.getElementById(id); 
		if (obj.style.display == "none"){ 
			obj.style.display = ""; 
		} else { 
			obj.style.display = "none"; 
		} 
	} 
} 
</script>
</head>

<body onload="hitPhpScript(); popular();">
<div class="container">
  <div class="header"><a href="#"><img src="/internal/datamining/logo.jpg" alt="Skytree Solutions" name="skytree_solutions" width="180" height="41" id="skytree_solutions" style="background: #C6D580; display:block;" /></a> 
  </div>
  <div class="sidebar1">
    <ul class="nav">
  	<?php
		//query menu
		$menu = "SELECT * FROM menu WHERE menu_confirm = '1'";
		//end of query menu
		
		//tampilkan menu
		if($menu=mysqli_query($conn,$menu)){
			while($row_menu =mysqli_fetch_array($menu,MYSQLI_ASSOC)){
				$menu_name_ = $row_menu['menu_name'];
				$menu_id_ = $row_menu['menu_id'];
	?>
                <li><a href="#"><?php echo $menu_name_; ?></a></li>
    <?php
			}
		}
	?>
    			<li><a href="/internal/datamining/keluar.php">LOGOUT</a></li>
    </ul>
    <!-- end .sidebar1 -->
  </div>
   
  <!--content-->
  <div class="content">
    <form id="form_search" name="form_search" method="post">
      <table width="100%" border="0">
        <tr>
          <td colspan="4"><strong>Find News</strong></td>
        </tr>
        <tr>
          <td colspan="2">Search Tag</td>
          <td width="3%">:</td>
          <td width="81%"><input type="text" name="txt_search" id="txt_search" /></td>
        </tr>
        <tr>
          <td colspan="2">Result Type</td>
          <td>:</td>
          <td><input type="text" name="txt_type" id="txt_type" /></td>
        </tr>
        <tr>
          <td colspan="2">Count</td>
          <td>:</td>
          <td><input type="text" name="txt_count" id="txt_count" /></td>
        </tr>
        <tr>
          <td colspan="2">Date</td>
          <td>:</td>
          <td><input type="text" name="txt_date" id="txt_date" /></td>
        </tr>
        <tr>
          <td colspan="4">&nbsp;</td>
        </tr>
        <tr>
          <td width="9%"><input type="submit" name="txt_submit" id="txt_submit" value="Find"/></td>
          <td width="7%"><input type="submit" name="txt_add_tag" id="txt_add_tag" value="Save Search Tag" /></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td colspan="4">&nbsp;</td>
        </tr>
      </table>
    </form>
    <div id="hasil_cari"></div>
    <div id="save_tag"></div>
    <br />  
    
    <!--<span id="countdown_label"></span>-->
    <span id="link"></span> 
    <span id="countdown_label2"></span>
    <span id="popular"></span> 
  </div>
  <!--end of content-->
  
  <div class="footer">
    <p>Copyright Skytree Solutions, 2015 </p>
  <!-- end .footer --></div>
  <!-- end .container --></div>
</body>
</html>
