<?php   session_start();

if ( $_SESSION[ invcox ] == "" ) { header( "location:login.php?action=need" );} else { include( "config.php" );
   	?>

<!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=iso-8859-1"/>
      <title>Employee Leave</title>
      <link href="style.css" rel="stylesheet" type="text/css"/>
      <?php include("calendar.php");
?>   
   </head>
   <body>
      <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="box-wrap">
         <tr>
            <td>   <?php include("top.php");
?></td>
         </tr>
         <tr>
            <td>
               <table width="100%" border="0" cellspacing="1" cellpadding="0">
                  <tr>
                     <td align="left" class="link2">&nbsp;
</td>
                  </tr>
            
                  <tr>
                     <td align="center">&nbsp;
</td>
                  </tr>
                  <tr>
                     <td>
                        <form action="insert_leave.php" method="post" enctype="multipart/form-data" name="form1" class="round_box" id="form1">
                           <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
                              <tr>
                                 <td height="40" colspan="2" align="center" bgcolor="#466c74">Employee Leave</td>
                              </tr>
                              <?php if($_GET[info]!=""){?>
                              <tr>
                                 <td height="40" colspan="2" align="center" bgcolor="#80E8F4"><?php echo $_GET[info];
 ?>   </td>
                              </tr>
                              <?php }
							   

$result=mysql_query("select * from hr_salary  where id='$_GET[id]' limit 1");
$row=mysql_fetch_array($result);
																					  
$aresult=mysql_query("select * from hr_employee  where id='$row[employee]' limit 1");
$arow=mysql_fetch_array($aresult);																					  
							   ?>
                              <tr>
                                <td width="14%" bordercolor="#CCCCCC"> Employee :</td>
                                <td width="86%" bordercolor="#CCCCCC" class="input200"><select name="employee" required="required" id="employee">
                                  <?php 
$today=date("Y-m-d");
 
		  $result=mysql_query("select * from hr_employee where date1<='$today' and date2='0000-00-00' or date1<='$today' and date2>='$today'  order by id asc");
		  $row=mysql_fetch_array($result);

		  do{

		  ?>
                                  <option value="<?php echo $row[id]; ?>"><?php echo $row[customer_name]; ?></option>
                                  <?php 

		  }while($row=mysql_fetch_array($result));

		  ?>
                                </select></td>
                              </tr>
                              <tr>
                                <td> Leave from  *</td>
                                <td class="input200"><table width="180" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="70%"><input name="cdate" type="text" id="cdate" size="15"  value="<?php echo date("d-m-Y");?>" required="required"/></td>
                                    <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('cdate', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
                                  </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td> Leave To *</td>
                                <td class="input200"><table width="180" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="70%"><input name="cdate2" type="text" id="cdate2" size="15"  value="<?php echo date("d-m-Y");?>" required="required"/></td>
                                    <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('cdate2', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
                                  </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td>Comments :<span class="red">*<span class="input200">
                                  <input name="id" type="hidden" id="id" value="<?php echo $_GET[id];?>"/>
                                </span></span></td>
                                <td class="input200"><input name="commentx" type="text" id="commentx" value="<?php echo $row[commentx];?>" /></td>
                              </tr>
                              <tr>
                                 <td height="50" align="center">&nbsp;
</td>
                                 <td height="50" align="left"><input type="submit" name="Submit23" value="Submit"/>   </td>
                              </tr>
                           </table>
                        </form>
                     </td>
                  </tr>
                 
                 
               </table>
            </td>
         </tr>
         <tr>
           <td height="28" align="center">&nbsp;</td>
         </tr>
         <tr>
           <td  class="round_box"><table width="100%" border="0" align="center" cellpadding="3" cellspacing="0" class="list_table">
             <tr>
               <th height="30">SL</th>
               <th height="30" align="center">Employee</th>
               <th>Leave from</th>
               <th>Leave To</th>
               <th>Days</th>
               <th height="30" align="left">Comments</th>
               <th >User</th>
               <th width="202" height="30" align="center"><span class="style23">Edit</th>
             </tr>
             <?php $page_name="hr_leave.php?id=$_GET[id]";
 	$limit=$_GET['limit'];
	$start=$_GET['start'];
if(!($start > 0)) {	$start = 0;
	}	$eu = ($start - 0);
 	$limit = '50';
   	$this1 = $eu + $limit;
 	$back = $eu - $limit;
 	$next = $eu + $limit;
$ant=mysql_query("select * from hr_leave order by id desc ");
$nume=mysql_num_rows($ant);
$result=mysql_query("select * from hr_leave order by id desc limit $eu, $limit");
$row=mysql_fetch_array($result);
$sr=0;
do{

$aresult=mysql_query("select * from hr_employee where id='$row[employee]' limit 1");
$arow=mysql_fetch_array($aresult);
	
							
							$sr++;?>
             <tr>
               <td width="88" align="center" valign="top" class="link">
                 <?php    echo $row[id];?>              </td>
               <td width="322" align="center" valign="top" class="link "><?php echo $arow[customer_name];
   ?></td>
               <td width="145" align="center" valign="top" class="link"><?php    echo dtformat($row[cdate]);
            ?></td>
               <td width="148" align="center" valign="top" class="link"><?php    echo dtformat($row[cdate2]);
            ?></td>
               <td width="130" align="center" valign="top" class="link"><span class="link "><?php echo $row[leave_days];
 ?></span></td>
               <td width="329" align="left" valign="top" class="link "><?php echo $row[commentx];
 ?></td>
               <td width="98" align="center" class="link"><?php  
			  
$eresult=mysql_query("SELECT  userid FROM user WHERE id = '$row[suser]'  limit 1");
$erow=mysql_fetch_array($eresult);
				
			  echo $erow[userid];
				?>
                   <span class="info-icon" onclick="openPopup('show_ip_info.php?ip=<?php echo $row[user_ip]; ?>&amp;time=<?php $date = "$row[datetime1]";
echo date("d-m-Y H:i:s", strtotime($date));?>')">i</span></td>
               <td width="202" align="center" class="link">
               <?php if($hr_salary_edit == "1"){?>
               <a href="edit_leave.php?id=<?php echo $row[id]; ?>">Edit</a>
               <?php }?>
               </td>
             </tr>
             <?php }while($row=mysql_fetch_array($result));
?>
           </table></td>
         </tr>
         <tr>
           <td><table border="0" align = "center" cellpadding="0" cellspacing="2">
             <tr>
               <?php if($back >=0) { echo  "<td  align='left' class='paiging' width='60px'><a href='$page_name&start=$back&limit=$limit'><< PREV</a></td>";
 } //// Let us display the page links at  center. We will not display the current page as a link //?>
               <?php $i=0;
$l=1;
for($i=0;
$i < $nume;
$i=$i+$limit){if($i <> $eu){if($srx == "50"){$srx=0;
 echo '</tr><tr>';
}?>
               <td width="25px" align="center" class="paiging"><?php echo " <a href='$page_name&start=$i&limit=$limit'>$l</a>";
?></td>
               <?php }else{echo "<td align='center' width='25px'><span class='paiging_red'>$l</td>";
}/// Current page is not displayed as link and given font color red$l=$l+1;
$srx=$srx+1;
}?>
               <?php 
 ///////////// If we are not in the last page then Next link will be displayed. Here we check that 
																					  
/////if($this1 < $nume) { echo "<td  align='right' class='paiging' width='60px'><a href='$page_name&start=$next&limit=$limit'>NEXT >></a></td>";} 
					  
					  ?>
             </tr>
           </table></td>
         </tr>
         <tr>
            <td height="28"><?php include("bot.php");
?></td>
         </tr>
      </table>
   </body>
</html>
<?php }?>