<?php
date_default_timezone_set('Asia/Calcutta');
$out_date		= date("Y-m-d");
if(isset($_POST['okey']) && !empty($_POST['okey']))
{
	
$_SESSION['att_month']          = $_POST['month'];
$_SESSION['att_year']           = $_POST['year'];
$_SESSION['att_emp_name']       = $_POST['emp_name'];	
$_SESSION['att_state']     		= $_POST['state'];	
}
function attend_type($id)
{
	$sql_st	= mysql_query("SELECT `symbol` FROM `tbl_attend_type` where `id`='$id' ")or die(mysql_error());
	$row_st	= mysql_fetch_array($sql_st);
	return $row_st['symbol'];
}
?>
  <style>
  .table1 td{vertical-align: middle;text-align: center;}
  .color_1{background:#0C0 !important;color:#000 !important;}
  .color_2{background:#F00 !important;color:#fff !important;}
  .color_3{background:#33F !important;color:#FFF !important;}
  .color_4{background:#F39 !important;color:#FFF !important;}
  .color_5{background:#306 !important;color:#FFF !important;}
  .color_6{background:#90F !important;color:#FFF !important;}
  .color_7{background:#FF6 !important;color:#000 !important;}
  </style>
         
                <div class="span12" style="margin-left:0px;">
                    <div class="head clearfix">
                        <div class="isw-ok"></div>
                        <h1>ISR Details</h1>                        
                    </div>                    
                    <div class="block-fluid">  
   					   <form target="_blank" method="POST" enctype="multipart/form-data" action="pages/invoice/print_2.php" > 
					<?php /* 	<div class="row-form clearfix">
                           <div class="span1">        
                                   <label>Year</label>		
                              	 <select name="year">
                                        <option value="">Year</option>
                                        <?php 
										for($i=2010;$i<2056;$i++){?>
                                        
                                        <option value="<?php echo $i;?>" <?php if(isset($_SESSION['att_year']) && $_SESSION['att_year']==$i) { echo "selected";}  ?> ><?php echo $i;?></option>
                                        <?php } ?>
                                   </select>
                               </div>      
                            <div class="span3">
                        <label>State</label>
                        <select name="state" onchange="get_staff_name(this.value);" required>
                        <option value='ALL' >ALL</option>
                        <?php
                        if($_SESSION['userid']==4)
                        {
                            $st		= array();
                            $sql_st	= mysql_query("SELECT distinct `state` FROM `tbl_emp_records` ORDER BY `state` ASC ")or die(mysql_error());
                            while($row_st= mysql_fetch_array($sql_st))
                            {
                                array_push($st,$row_st['state']);
                            }
                        }
                        else
                        {
                            $st	  = explode('&',$_SESSION['post']);
                        }
                        foreach($st as $key)
                        {
                            $type = '';
                            if(isset($_SESSION['att_state'])&&($_SESSION['att_state']==$key)){ $type ='selected';}
                            echo "<option value='$key' $type>$key</option>";
                        }
                        ?>
                        </select>
                    </div>             
                    <div class="span3">        
                            <label>Employee Name</label>
                               <select name="emp_name" id="emp_name">
                               <option value='ALL'>ALL</option>
                               <?php
							   if(isset($_SESSION['att_state']))
								{
									
									$sql_st	= mysql_query("SELECT `emp_name`,`id` FROM `tbl_emp_records` where `state`='".$_SESSION['att_state']."' and `status`='0' ORDER BY `emp_name` ASC ")or die(mysql_error());
									while($row_st= mysql_fetch_array($sql_st))
									{
									?>
                                    <option value="<?php echo $row_st['id'];?>" <?php if($row_st['id']==$_SESSION['att_emp_name']){echo "selected";}?>><?php echo $row_st['emp_name'];?></option>
                                    <?php	
									}
								}
								?>
	                           </select>
                           </div>                                                              
                            <div class="span2"> 
                            <label>&nbsp;</label>
                     		<input type="submit" name="okey" value="Search"/>
                            </div>
                            </div><?php */?> 
                            <div class="row-form clearfix">
                            <div class="span2">        
                                   <label>Invoice Prifix</label>		
                              	    <select name="invoice_prefix">
                                        <option value="">Select</option>
                                        <option value="RHLLP/2018-2019/">RHLLP/2018-2019/</option>
                                        <option value="RHLLP/2019-2020/">RHLLP/2019-2020/</option>
                                        <option value="RHLLP/2020-2021/">RHLLP/2020-2021/</option>
                                        <option value="RHLLP/2021-2022/">RHLLP/2021-2022/</option>
                                   </select>
                               </div>
                            <div class="span3">        
                            <label>invoice No</label>
                            <input type="text" name="invoice_no" id="invoice_no" required />
                            </div>                                                              
                            <div class="span2"> 
                            <label>&nbsp;</label>
                     		<input type="submit" name="okey" value="Search"/>
                            </div>
                            </div>                      
                   </form>
                   </div>   
                </div>
<script>
function get_staff_name(state)
{
	if (state == '') {
		alert("Please Select State !!!");
		return;
	} else {
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
			{
				document.getElementById("emp_name").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","ajax/get_staff_name.php?state="+state,true);
		xmlhttp.send();
	}
	
}
</script>