<?php
if(basename($_SERVER['PHP_SELF']) == 'vemployee.php') {
  $pr=" class='current'";
} else {
  $pr="";
} 
include'header.php';

$code=$_GET['id'];

if(isset($_POST['sus_id']))
		{
			$code=$_POST['rowid'];
		$then=mysqli_query($conn, "UPDATE `employees` SET `Status`='1' WHERE `Eid`='$code' ORDER BY `Eid` ASC LIMIT 1");
		}
		
if(isset($_POST['delox']))
		{
			$rowid=$_POST['rowid'];
		$then=mysqli_query($conn, "UPDATE `employees` SET `Status`='1001' WHERE `Eid`='$rowid' ORDER BY `Eid` ASC LIMIT 1");
		}

if(isset($_POST['usus_id']))
		{
			$code=$_POST['rowid'];
		$then=mysqli_query($conn, "UPDATE `employees` SET `Status`='0' WHERE `Eid`='$code' ORDER BY `Eid` ASC LIMIT 1");
		}

$do=mysqli_query($conn, "SELECT *FROM `employees` WHERE `Eid`='$code' ORDER BY `Eid` ASC LIMIT 1");
while($ro=mysqli_fetch_assoc($do)){
$rowid=$ro['Eid'];
$fname=$ro['Fname'];
$lname=$ro['Lname'];
$depart=$ro['Depart'];
$birth=$ro['Birth'];
$contact1=$ro['Contact1'];
$contact2=$ro['Contact2'];
$idno=$ro['Idno'];
$currentp=$ro['Currentp'];
$address=$ro['Address'];
$gender=$ro['Gender'];
$email=$ro['Email'];
$password=$ro['Password'];
$confirm_password=$ro['Password'];
$bank=$ro['Bank'];
$branch=$ro['Branch'];
$city=$ro['City'];
$account=$ro['Account'];
$remarks=$ro['Remarks'];
$father=$ro['Father'];
$mother=$ro['Mother'];
$rssb=$ro['Rssb'];
$salary=number_format($ro['Salary']);
$qualify=$ro['Qualify'];
$start=$ro['Starting'];
$status=$ro['Status'];
$photo=$ro['Photo'];
$file1=$ro['File1'];
$file2=$ro['File2'];
$file3=$ro['File3'];
	if(!$photo)
		$photo="imgs/-text.png";
	else
		$photo="photos/$photo";
}

if($_SESSION['Empopa'])
$btol="";
else
$btol="disabled";

if($status=='1'){
	$cool=" style='color:#DBBAA3'";
	$btn="<button class='btn btn-primary btn-block btn-success' name='usus_id' style='width:100px;' onclick='return checkDeleteu()' $btol>Unsuspend</button>";
}
else{
	$cool="";
	$btn="<button class='btn btn-small btn-block btn-warning' name='sus_id' style='width:100px;' onclick='return checkDelete()' $btol>Suspend</button>";
}

if($file1)
	$dfile1="&raquo;&raquo;&nbsp;File1&nbsp;:&nbsp;<a href='down_file1.php?link=$file1' title='Click to download file 1'>Download&nbsp;File&nbsp;1</a>";
else
	$dfile1="&nbsp;File1&nbsp;:&nbsp;None";

	if($file2)
	$dfile2="&raquo;&raquo;&nbsp;File2&nbsp;:&nbsp;<a href='down_file2.php?link=$file2' title='Click to download file 2'>Download&nbsp;File&nbsp;2</a>";
else
	$dfile2="&nbsp;File2&nbsp;:&nbsp;None";

	if($file3)
	$dfile3="&raquo;&raquo;&nbsp;File3&nbsp;:&nbsp;<a href='down_file3.php?link=$file3' title='Click to download file 3'>Download&nbsp;File&nbsp;3</a>";
else
	$dfile3="&nbsp;File3&nbsp;:&nbsp;None";

$de=mysqli_query($conn, "SELECT *FROM `depart` WHERE `Number`='$depart' ORDER BY `Number` ASC");
			  $re=mysqli_fetch_assoc($de);
					$depart=$re['Depart'];
?>
<div class="container-fluid main-content">
<div class="page-title">
<div class="row">
<div class="col-md-6">
<h1 style='margin-top:-20px; margin-bottom: 5px;'>Employee Profile</h1>
</div>
<div class="col-md-6">
 <div class="col-md-5 pull-right" style='text-align:right;'>
 <form method='post' action='vemployee.php'>
 <?php
	echo"<input type='hidden' name='rowid' value='$code'>";
	?>
	<table><tr><td align='right'> <?php echo $btn ?></td>
</form> <form method='post' action='new_employee.php'>
	<td align='right'> <?php
	echo"<input type='hidden' name='rowid' value='$code'>";
	?>
	<button class="btn btn-primary btn-block" name='edit_id' style='width:100px;' <?php echo $btol ?>>Edit</button>	
	</td></tr></table></form>
 </div></div>
</div></div>
  <div class="row">
        <div class="col-md-2">
		<ul class="list-group">
			 	<li class="list-group-item">
           <a href="employees.php">
           <p>
           <i class="lnr lnr-menu-circle"></i>&nbsp;List of Employees
           </p></a>
           </li>
           
                <li class="list-group-item">
           <a href="susprepo.php">
           <p>
           <i class="lnr lnr-menu-circle"></i>&nbsp;Suspended List
           </p></a>
           </li> 
                <li class="list-group-item active">
           <a href="new_employee.php">
           <p>
           <i class="lnr lnr-plus-circle"></i>&nbsp;Create Employee
           </p></a>
           </li>
                       </ul>
		
         
  
            <div class="widget-container fluid-height">
              <div class="widget-content">
               
                <div class="panel-group" id="accordion">
                  <div class="panel">
                    <div class="panel-heading">
                    </div> 
                  </div>
                  <div class="panel">
                    <div class="panel-heading">
                      <div class="panel-title">
                      </div>
                    </div>
                    <div class="panel-collapse collapse in" id="collapseTwo">
                    </div>
                  </div>
                  <div class="panel filter-categories">
                    <div class="panel-heading">
                      <div class="panel-title">
               <a class="accordion-toggle collapsed" data-parent="#accordion" data-toggle="collapse" href="#collapseThree">
                        <div class="caret pull-right"></div>  
                        Calculation</a>
                      </div>
                    </div>
                    <div class="panel-collapse collapse in" id="collapseThree">
                      <div class="panel-body">
                      <form method="POST" action="employees.php">
                      <input value="view_employees" name="user" type="hidden">
                      <select class="form-control" name="department">
                      <option selected="selected" value="">Show All</option>
 <?php
		$de=mysqli_query($conn, "SELECT *FROM `depart` ORDER BY `Number` ASC");
			  while($re=mysqli_fetch_assoc($de)){
					$ne=$re['Number'];
					$dep=$re['Depart'];
			echo"<option value='$ne' $sed>$dep</option>";
			  }
			  ?>                      
                      </select><br>
                      <button class="btn btn-block btn-primary" type="submit" name="submitfilter">
                      <i class="lnr lnr-checkmark-circle"></i> Submit</button>
                      </form></div></div>   </div>
                </div>
              </div>
            </div>        
         </div>
 
  <div class="col-md-10" <?php echo $cool ?>>  
<div class="col-md-3">
            <div class="widget-container fluid-height">
              <div class="heading">
                <h4>Profile Picture</h4>
              </div>
              <div class="widget-content padded " style="text-align:center;">
                            	<img src="<?php echo $photo ?>" width="60%"><br><br>
								Gender: <?php echo $gender ?>  <hr><div style='padding-top:16px;'>
				 <?php 
				 if($contact2)
				 echo"Driving ID: $contact2 "; 
				 else
				 echo"Driving ID: N/A "; ?></div>
                            </div>
            </div>
          </div>
          <div class="col-md-5">
            <div class="widget-container fluid-height">
              <div class="heading">
               <h4>Personal Details</h4>
              </div>
             <div class="widget-content padded">
  <strong>Full Name:</strong>
   <p><?php echo" $fname $lname "; ?></p>
    <strong>Username:</strong>
     <p><?php echo $email ?></p>
     <strong>Telephone No:</strong>
    <p><?php echo"$contact1" ?></p>
  <strong>Date Of Birth:</strong>                  
 <p><?php echo $birth ?></p>
 <strong>Address:</strong>                
 <p><?php echo $address ?></p>            
 </div>
  </div>
   </div>
          <div class="col-md-4">
            <div class="widget-container fluid-height">
              <div class="heading">
                <h4>Official Details</h4>
              </div>
              <div class="widget-content padded">
             <strong>Father`s Name:</strong>
                  <p><?php echo $father ?>                 </p>
         <strong>Mother`s Name:</strong>
                 <p><?php echo $mother ?>                  </p>
                  <strong>Registration</strong> No:</strong>
                 <p><?php echo $code ?></p>
                  <strong> Current Post:</strong>
		<?php
			$dei=mysqli_query($conn, "SELECT *FROM `position` WHERE `Postid`='$currentp' ORDER BY `Postname` ASC");
			 if($fei=mysqli_num_rows($dei)){
				 $rei=mysqli_fetch_assoc($dei);
					$post=$rei['Postname'];
			echo"<p> $post </p>";
			 }
			 else
				echo"<p> N/A </p>";
			?>
                  <strong>Salary:</strong>
                 <p>RWF&nbsp;<?php echo $salary ?>
                 </p>
              </div>
            </div>
          </div>
        </div>

</div>
<div class="row"> </div>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-10" <?php echo $cool ?>>
<div class="col-md-4">
<div class="widget-container fluid-height clearfix">
<div class="heading"><h4>Related Documents</h4></div>
<div class="widget-content padded"><center>
     
                    <?php echo $dfile1 ?>
                            <br> 

  
                    <?php echo $dfile2 ?>
                            <br>       


                    <?php echo $dfile3 ?>
                                 <br><br>
 </center></div>
 </div>
</div>
<div class="col-md-4">
<div class="widget-container fluid-height clearfix">
 <div class="heading"><h4>Identity Documents</h4></div>
 <div class="widget-content padded">
 <strong>ID/Passport No : </strong>&nbsp;&nbsp;<?php echo $idno ?>        <br>    
         <p></p>
        <strong>RSSB Number &nbsp;&nbsp;: </strong> &nbsp;&nbsp; <?php echo $rssb ?>     <p> 
             </p>
  </div> 
 </div>
</div> <div class="col-md-4">
<div class="widget-container fluid-height clearfix">
 <div class="heading"><h4>Bank details</h4></div>
 <div class="widget-content padded">
                <ul>
				<li>
                 <strong>Bank Name: </strong> &nbsp;&nbsp; <?php echo $bank ?>                  </li>
                  <li>
                    <strong>Account Number: </strong> &nbsp;&nbsp; <?php echo $account ?>                    </li>
                  <li>
                  <strong>Branch:  </strong>&nbsp;&nbsp; <?php echo $branch ?>                    </li>
				  </ul>
  </div> 
 </div>
</div></div>
</div>

<div class="row">
<div class="col-md-2"></div>
<div class="col-md-10">

<div class="widget-container fluid-height clearfix" style='width:99%; float:center;'>
 <div class="heading"><h4>Additional Information&nbsp;&nbsp;&nbsp;&nbsp;<br><br>
 <div align='left'><span class="badge"><?php echo $code ?></span></div></h4>
 <strong></strong>
 </div></div>
 
 <div class="widget-content padded">
 <div class="col-md-12">
 <div class="col-md-6">
       
       <?php
            if($_SESSION['Access']=='ADMINISTRATOR'){
                $dbutn="submit";
                $disa="Delete This User";
            }
            else{
                $dbutn="button";
                $disa="You are not allowed to use this button";
            }
                
    echo"<div class='modal fade' id='modal-dele' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true' 
		style='top:120px;'>
  <div class='modal-dialog' role='document'>
    <div class='modal-content text-left'>
      <div class='modal-header'>
        <h5 class='modal-title' id='exampleModalLabel'>DELETE CONFIRMATION 
		<label class='text-right pull-right'> $fname $lname </label></h5>

      </div><div class='modal-body' style='height:60px;'>
  <h5 style='color:#ff0033'>Are you sure you want to delete this employee?</h5>
      </div><form method='post' action=''>
      <input type='hidden' name='rowid' value='$rowid'>
      <div class='modal-header' style='height:50px; padding:10px; border:0px solid blue; text-align:right'>
    <button type='button' class='btn btn-sm btn-success' data-dismiss='modal'>&nbsp;NO&nbsp;</button>
    <button type='$dbutn' name='delox' class='btn btn-sm btn-danger' title='$disa' data-toggle='tooltip' data-placement='top'>YES</button>
      </div></form>
    </div>
  </div>
</div>"; 
       
       ?></div>
                
                
                <div class="col-md-6 text-right">
        <button type="button" class="btn btn-xs btn-danger hidden-print text-center" style="height:24px; padding:0px; margin-top:-10px;" 
		data-placement='top' data-toggle='modal' data-target='#modal-dele'>&nbsp;&nbsp;&nbsp;&nbsp;<i class='lnr lnr-trash'></i>&nbsp;&nbsp; Delete This Employee&nbsp;&nbsp;&nbsp;&nbsp;</button>
                
                </div>
                </div><br><br><br>
  </div> 
 </div>
      


<?php
include'footer.php';
?>