<link rel="stylesheet" href="css/new_mxerp.css">
<form name="search" action="" method="post">
<div class="body_contain">
<div class="tab_div"> 
<div id="PickedItems" style="display:none"></div>
<h1>EMPLOYEE DOCUMENT UPLOAD</h1>

<?php  $url='&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'];
$emp_id  =  $s->GetFieldValue("www_users","id='".$_SESSION['UserID']."' ","empid");
/*
if(isset($_REQUEST['action']) && $_REQUEST['action']=="delete_tds"  && isset($_REQUEST['id'])){
  //&& isset($_REQUEST['emp_id'])
        
      DB_query("Delete from hr_employee_doc_upload WHERE id='".$_REQUEST['id']."'",$db);
    }
*/
if($_REQUEST['Delete'])
{
   //echo count($_REQUEST['leadid']);
   //exit;
  for($i=0;$i<count($_REQUEST['leadid']);$i++)
  {
    $condition="id='".$_REQUEST['leadid'][$i]."'";
    $s->DeleteRecord('hr_employee_doc_upload', $condition);
    //$condition="id='".$_REQUEST['leadid'][$i]."'";
    //$s->DeleteRecord('spare_part_kits', $condition);
  }
  //$s->pageLocation("index.php?route=HRModule/holidays");
}

?>

<form action="" method="post" name="myform" >
 <!-- <table width="100%" border="0" cellpadding="3" cellspacing="0">
  <tr class="row1">
  <td width="13%"><strong>Employee</strong></td>
  <td width="35%">
    <?php //print_r($_SESSION); ?>

    <select name="emp"  style="width:98%;">
    <option value="">---Select---</option>
  <?php 
     
     if($_SESSION['UserType']=='SuperAdmin'){
      $Sitesql="select * from empmaster  order by emp_name ASC";
    }
    else{
      $Sitesql="select * from empmaster  where id='".$emp_id."' order by emp_name ASC";
    }
  $SiteRes=DB_query($Sitesql,$db);
  while($SiteRow=DB_fetch_array($SiteRes)){?>
            <option value="<?php  echo $SiteRow['id'];?>" <?php  echo $_REQUEST['emp']==$SiteRow['id']?'selected':''?> >
            <?php  echo $SiteRow['emp_name'];?>
            </option>
<?php }?>
          </select>
  </td>
  <td width="13%"><strong>Finincial Year</strong></td>
  <td width="35%"><select name="fin_year"  style="width:98%;">
    <option value="">---Select---</option>
  <?php $finyearsql="SELECT * FROM `company_financial_years` order by id desc";
      $finyearsqlRes=DB_query($finyearsql,$db);
      while($finyeaRow=DB_fetch_array($finyearsqlRes)){?>
            <option value="<?php  echo $finyeaRow['id'];?>" <?php  echo $_REQUEST['fin_year']==$finyeaRow['id']?'selected':''?> >
            <?php  echo date('Y',strtotime($finyeaRow['year_start']))."-TO- ".date('Y',strtotime($finyeaRow['year_end']));?>
            </option>
<?php }?>
          </select>
  </td>

  <td width="13%" ><strong> <input name="Search" type="submit" class="search" value="Search"/></strong></td>
  <td></td>
  
</tr>
<tr class="row1">
  <td style="text-align:left;" colspan="6">
 
  </td>
</tr>
  </table>
  </form>-->

<?php
//if(in_array($_SESSION['UserID'],$Explode))
//{



if($_REQUEST['Search']){
$filter='1=1';
    
  

  if($_REQUEST['fin_year']!='' ) 
   {
     $filter.=" and fin_year='".$_REQUEST['fin_year']."' ";
   }
   if($_REQUEST['emp']!='' ) 
   {
     $filter.=" and emp_id='".$_REQUEST['emp']."' ";
   }

  if($_SESSION['UserType']=='SuperAdmin'){

     $SQL=DB_query("SELECT * FROM `hr_declaration_head` where $filter ",$db);
  }
  else{
     $SQL=DB_query("SELECT * FROM `hr_declaration_head` where $filter and emp_id='".$emp_id."'",$db);
  }

}
else{
  if($_SESSION['UserType']=='SuperAdmin'){

     $SQL=DB_query("SELECT * FROM `hr_employee_doc_upload`",$db);
  }
  else{
     $SQL=DB_query("SELECT * FROM `hr_employee_doc_upload`",$db);
  }

} 



?>

  <p align="left">
    <input class="search" type="button" value="Uploads" onclick="pop()">
    <?php if($_SESSION['frmDelete']=='1'){?>&nbsp;<input type="submit" name="Delete" value="Delete" class="search" onClick="return confirm('Are you sure you want to delete this Item record?');" /><?php } ?>
  </p>
 <table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid; border-collapse:collapse;"> 
<tr>
  <td width="2%"><input type="checkbox" id="selecctall"/></td>
  <td width="3%"><strong>S. No.</strong></td>
  <td width="30%"><strong>Employe Type</strong></td>
  <td width="20%"><strong>Document Title</strong></td>
  <td width="20%"><strong>Document Name</strong></td>
  <td width="7%" style="text-align:center;"><strong>Document</strong></td>
  <!--<td width="7%" style="text-align:center;"><strong>Action</strong></td>-->
</tr>
<?php 
$i=1;
//$SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where $filter1 and status='accept' and conf_int_app_details_seq ='".$oldseq."'"


while($GetRec=DB_fetch_array($SQL)) {
  $applicantid=$GetRec['id'];
 // $qt=DB_num_rows(DB_query("SELECT * FROM hr_applcnt_rgstn_ref where hr_applcnt_rgstn_id='".$GetRec['mainid']."' and akk_status='ok'",$db));
//if($qt>=2){
  ?>
  <tr bgcolor="#fff">
        <td width="2px"><input name="leadid[]" type="checkbox" class="checkbox1" id="leadid_<?php echo $i+1; ?>" value="<?php echo $GetRec['id']?>" /></td>
        <td><?php echo $i; ?></td>         
        <td><?php echo ucfirst($GetRec['emp_type']) ;?></td>
        <td><?php echo ucfirst($GetRec['title']) ;?></td>
        <td><?php echo ucfirst($GetRec['name']) ;?></td>            
        <td style="text-align:center;"><a href="uploaded_docs/HR/emp_doc/<?php echo $GetRec['emp_doc'] ;?>"><img width="15" height="15" title="Download" src="images/download1.png"></a></td> 
        <!--<td style="text-align:center;"><a href="index.php?route=HRModule/Master/employee_doc_upload&action=delete_tds&id=<?php echo $GetRec['id']; ?><?php echo $rurl;?>" ><img width="15" height="15" title="Delete" src="images/Icon_Delete.png"></a></td>        
        --></tr>
        <?php $i++; }// } ?>
</table>
</div>
</div>
</form>

<?php

?>
<script type="text/javascript" language="javascript">
//$.noConflict();
function pop(id,frmid,modid){
 // alert(id);
  //alert(str);
  $("#PickedItems").dialog({
                title:'Employee Document Uploading',
                modal: true,
                resizable: false,
                width:900,
                height:400,
                closeText: 'fechar',
                draggable: true,
                show: 'fade',
                hide: 'fade',
                dialogClass: 'main-dialog-class',
                buttons: {
                        Exit: function()
                        {
                                $(this).dialog("close");
                        }
                }

            });
   Getemployeelist(id,frmid,modid);
}

    
function Getemployeelist(id,frmid,modid)
{ 
  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)
    {
       // alert(xmlhttp.responseText);
    document.getElementById("PickedItems").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST",'ajax_employee_doc_upload.php',true);
xmlhttp.send();
}

function pop1(id,frmid,modid){

  $("#PickedItems").dialog({
                title:'Document Uploading View',
                modal: true,
                resizable: false,
                width:900,
                height:400,
                closeText: 'fechar',
                draggable: true,
                show: 'fade',
                hide: 'fade',
                dialogClass: 'main-dialog-class',
                buttons: {
                        Exit: function()
                        {
                                $(this).dialog("close");
                        }
                }

            });
   Getemployeelist1(id,frmid,modid);
}
    
function Getemployeelist1(id,frmid,modid)
{ 
  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)
    {
       // alert(xmlhttp.responseText);
    document.getElementById("PickedItems").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST",'ajax_invest_doc_updating_view.php?id='+id+'&modid='+modid+'&frmid='+frmid,true);
xmlhttp.send();
}
function GetEmployes(emptypeid)
{ 
  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)
    {
       // alert(xmlhttp.responseText);
    document.getElementById("emp_id").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST",'GetemployeeList.php?emptypeid='+emptypeid,true);
xmlhttp.send();
}



function LeadData()
{ 
  myCheckboxArray = document.myform.elements["leadid[]"];
  var t=myCheckboxArray.length;
  //alert(myCheckboxArray);
  if(document.getElementById('leadid').checked==true)
  { 
  if(t==undefined)
  document.getElementById('leadid_'+1).checked=true;    
  for (var i = 1; i <= t; i++)
  {
  document.getElementById('leadid_'+i).checked=true;  
  } 
  }
  else
  {
  if(t==undefined)    
  document.getElementById('leadid_'+1).checked=false;   
  for (var i = 1; i <= t; i++)
  {
  document.getElementById('leadid_'+i).checked=false; 
  }
  }
}
$(document).ready(function() {
    $('#selecctall').click(function(event) {  //on click
        if(this.checked) { // check select status
            $('.checkbox1').each(function() { //loop through each checkbox
                this.checked = true;  //select all checkboxes with class "checkbox1"              
            });
        }else{
            $('.checkbox1').each(function() { //loop through each checkbox
                this.checked = false; //deselect all checkboxes with class "checkbox1"                      
            });        
        }
    });
   
});

</script>
