<?php
session_start();
$session_id ='1';
 

if( isset($_POST['logname']) && isset($_POST['logsecret'])){

$val=$_POST['loginbutton']; 


$name=$_POST['logname'];

$secret=$_POST['logsecret'];

 include("buda_connect.php");

 
						   
						   
$valid=mysql_query("select owner_id from owner_credential where  username= '$name' and secret_no='$secret'") or die("Error:".mysql_error());

$no=mysql_num_rows($valid);

if($no>0){
	$re = array();
	
	$outD = mysql_fetch_array($valid);
	
	array_push($re,array( 'owner_id'=>$outD[0]
	                       
	                       ));   
						   
						   





$chCate=mysql_query("select own_regno,fname,mname, lname, btown_dist,bstreet_vil,email,rtown,rstreet from   account_owner where owner_id='$outD[0]'") or die("Error:".mysql_error());

$ownO=mysql_num_rows($chCate);
if($ownO>0){
	$ownpro=array();
	
	$OwnD=mysql_fetch_array($chCate);
	
	array_push($ownpro, array('own_regno'=>$OwnD[0],
	                          'fname'=>$OwnD[1],
							  'mname'=>$OwnD[2],
							  'lname'=>$OwnD[3],
							  'btown_dist'=>$OwnD[4],
							  'bstreet_vil'=>$OwnD[5],
							  'email'=>$OwnD[6],
							  'rtown'=>$OwnD[7],
							  'rstreet'=>$OwnD[8]
	));
	
$hotel=mysql_query("select hotel_id,hname,ltown_city,lstreet_vil,paddress,email,reg_date from  hotel where owner_id='$OwnD[0]'")or die("Error:".mysql_error());

$hotno=mysql_num_rows($hotel);

if($hotno>0){
	
	 $gethoD = array();
	 
	 $OuthD=mysql_fetch_array($hotel);
	 
	 array_push($gethoD,array('hotel_id'=>$OuthD[0],
	                         'hname'=>$OuthD[1],
							 'ltown_city'=>$OuthD[2],
							 'lstreet_vil'=>$OuthD[3],
							 'paddress'=>$OuthD[4],
							 'email'=>$OuthD[5],
							 'reg_date'=>$OuthD[6]
							  
	             
				 ));
	 
	
	 					   
						  
?>



<blockquote>
<blockquote>
CUSTOMER ATTENTANCE REPORT GENERATOR.

<table border =0 class="spta" >


 <input type="text"id="hotelid"  class="hide" name="hotelid" value="<?php echo $OuthD[0];?>"/> 

<tr><td>Specify the type of report you need to view:<select id="rptype" onchange="reportSpecific()">

<option >Report category</option>
<option value="Annual"> Annual report</option>
<option value="monthly"> Monthly report</option>
<option value="Daily"> Daily report</option></select>
</td></tr>
 
  </table>
<table><tr><td><div id="detail"> </div></td></tr> </table>
</blockquote>
</blockquote>
<?php

}else{
	$test="TRUE";
}							   
//include("hotel_after_login_home.php");	
}else{
echo "Sorry you no hotel registered for advertisement!..";	
}						
	
}else{
	echo "You are not registered yet!..";
}

 

}else {
	echo "Hotel id not found!..";
}
?>
<script>
 function reportSpecific(){
	var sec =document.getElementById("rptype").value;
	$(".reportinfo").empty();
	if(sec=="Annual"){
		document.getElementById("detail").innerHTML="Specify year below:-";
		document.getElementById("detail").innerHTML +='<select id="year" onchange="annualReport()"><option value="">Year</option><option value="2016">2016</option><option value="2015">2015</option></select>';
	}
	
	
	else if(sec=="monthly")
	
	{
    document.getElementById("detail").innerHTML="Specify year and month below:-";
    document.getElementById("detail").innerHTML +='<select id="year" onchange="monthlyReport()"><option value="">Year</option><option value="2016">2016</option><option value="2015">2015</option></select>';
    document.getElementById("detail").innerHTML+='<select id="month" onchange="monthlyReport()"><option value="">Month</option></select>';
	var i;
	for(i=1; i<13; i++){
		if(i<10){
	document.getElementById("month").innerHTML+='<option value="0'+i+'">0'+i+'</option>';
		}else{
	
	document.getElementById("month").innerHTML+='<option value="'+i+'">'+i+'</option>';	
		}
	}
	}
	
	
	else if(sec=="Daily")
	
	{
	document.getElementById("detail").innerHTML="Specify year, month and date below:-";	
	
	
	
    document.getElementById("detail").innerHTML +='<select id="year" onchange ="daysInMonthYearBod()"><option value="">Year</option><option value="2016">2016</option><option value="2015">2015</option></select>';

    document.getElementById("detail").innerHTML+='<select id="month" onchange ="daysInMonthYearBod()" ><option value="">Month</option></select>';
	
	
	 
	var i;
	for(i=1; i<13; i++){
		if(i<10){
	document.getElementById("month").innerHTML+='<option value="0'+i+'">0'+i+'</option>';
		}else{
	
	document.getElementById("month").innerHTML+='<option value="'+i+'">'+i+'</option>';	
		}
	}
	
	document.getElementById("detail").innerHTML+='<select id="dai" onchange="dailyReport()"><option>Date</option></select>';
	 
	 
	}
	else{
	document.getElementById("detail").innerHTML='';
	}
}
function daysInMonthYearBod(){
	//document.getElementById("dai").innerHTML +='<option value=""> day </option>'; 
	var year = document.getElementById("year").value;
	var month= document.getElementById("month").value;
	if(year=="" || month==""){
		
		alert("Select both month and year!...");
}
else{
	 var days = new  Date(year,month,0).getDate();
	 var j;
	 for(j=1;j <= days;j++){
		 if(j > 9){
		 document.getElementById("dai").innerHTML +='<option value="'+j+'"> '+j+'</option>';
		 }
		 else{
			 var k=0;
			 document.getElementById("dai").innerHTML +='<option value="'+k+j+'">'+k+j+'</option>'; 
		 }
	 }

}
}
function annualReport(){
	var hid= document.getElementById("hotelid").value;
	var yr= document.getElementById("year").value;
	if(hid != "" && yr !=""){
		$.post('retrieve_customer_detail.php',{hotelID:hid,dat:yr},function(data){
		$(".reportinfo").html(data).show();	
			
		});
	}
	else{
		alert("Some information are not filled!.."+hid+yr);
	}
}

function monthlyReport(){
	var hid= document.getElementById("hotelid").value;
	var yr= document.getElementById("year").value;
	var mn= document.getElementById("month").value;
	if(yr===""){
		alert("Specify year of report!..");
	}else if(mn===""){
	alert("Specify month of report!..");	
	}else{
	if(hid != "" && yr !="" && mn!=""){
		var ym=yr+" -"+mn;
		$.post('retrieve_customer_detail.php',{hotelID:hid,dat:ym},function(data){
		$(".reportinfo").html(data).show();	
			
		});
	}
	else{
		alert("Some information are not filled!.."+hid+yr+mn);
	}
	}
}

function dailyReport(){
	var hid= document.getElementById("hotelid").value;
	var yr= document.getElementById("year").value;
	
	var mn= document.getElementById("month").value;
	
	var dai= document.getElementById("dai").value;
	
	if(hid != "" && yr !="" && mn!="" && dai!=""){
		var ym=yr+" -"+mn+"-"+dai;
		$.post('retrieve_customer_detail.php',{hotelID:hid,dat:ym},function(data){
		$(".reportinfo").html(data).show();	
			
		});
	}
	else{
		alert("Some information are not field!..");
	}
}
</script>