File: /var/www/grapossconnect/admin-dash/api/view_employee_details.php
<?php
require_once('../_dbconfig.php');
$empID = $_REQUEST['employeeid'];
if (!empty($empID)) {
$employeeQry = $conn->query("SELECT `id`, `first_name`, `last_name`, `birth_date`, `gender`, `email`, `phone_number`, `present_address`, `present_state`, `present_city`, `present_zipcode`, `permanent_address`, `permanent_state`, `permanent_city`, `permanent_zipcode`, `applying_position`, `marital_status`, `anniversary_date`, `childern`, `department`, `joinning_date`, `reporting_person`, `additional_notes`, `created_at` FROM `grp_employees` WHERE `id`='$empID'");
$showresult = $employeeQry->fetch_assoc();
$stateID = $showresult['present_state'];
$pstateID = $showresult['permanent_state'];
$cityID = $showresult['present_city'];
$pcityID = $showresult['permanent_city'];
//State
$stateQry = $conn->query("SELECT `state_id`, `state_name` FROM `grp_states` WHERE `state_id`='$stateID'");
$stateresult = $stateQry->fetch_assoc();
$pstateQry = $conn->query("SELECT `state_id`, `state_name` FROM `grp_states` WHERE `state_id`='$pstateID'");
$pstateresult = $pstateQry->fetch_assoc();
$cityQry = $conn->query("SELECT `city_id`, `city_name` FROM `grp_cities` WHERE `city_id`='$cityID'");
$cityresult = $cityQry->fetch_assoc();
$pcityQry = $conn->query("SELECT `city_id`, `city_name` FROM `grp_cities` WHERE `city_id`='$pcityID'");
$pcityresult = $pcityQry->fetch_assoc();
//Document
$employeedocQry = $conn->query("SELECT `id`, `employee_id`, `document`, `document_name`, `created_at` FROM `grp_document_files` WHERE `employee_id`='$empID' LIMIT 0,4");
$checkDoc = $employeedocQry->num_rows;
?>
<article class="panel-body">
<figure class="text-center">
<figcaption>
<h3><?php echo $showresult['first_name'] . ' ' . $showresult['last_name']; ?></h3>
<?php echo $showresult['present_address'] . ', ' . $showresult['present_city'] . ', ' . $stateresult['state_name']; ?>
<br> <strong>Phone Number :</strong> <?php echo $showresult['phone_number']; ?> - <strong>E-mail :</strong> <?php echo $showresult['email']; ?>
</figcaption>
</figure>
</article>
<article>
<h4><strong>Personal Details</strong></h4>
<div class="dropdown-divider"></div>
<dl class="dl-horizontal">
<dd><strong>Date of Birth : </strong> <?php echo date('F, d Y', strtotime($showresult['birth_date'])); ?></dd>
<dd><strong>Gender : </strong> <?php echo $showresult['gender']; ?></dd>
<dd><strong>Phone Number : </strong> <?php echo $showresult['phone_number']; ?></dd>
<dd><strong>Email Address : </strong> <?php echo $showresult['email']; ?></dd>
<dd><strong>Designation (Applying Position) : </strong> <?php echo $showresult['applying_position']; ?></dd>
<dd><strong>Marital Status : </strong> <?php echo $showresult['marital_status']; ?></dd>
<dd><strong>Department : </strong> <?php echo $showresult['department']; ?></dd>
<dd><strong>Joinning Date : </strong> <?php echo $showresult['joinning_date']; ?></dd>
<?php if ($showresult['reporting_person'] != '') { ?>
<dd><strong>Reporting Person : </strong> <?php echo $showresult['reporting_person']; ?></dd>
<?php } ?>
<?php if ($showresult['marital_status'] == 'Married' && $showresult['anniversary_date'] != '') { ?>
<dd><strong>Anniversary Date : </strong> <?php echo date('F, d Y', strtotime($showresult['anniversary_date'])); ?></dd>
<?php } ?>
<?php if ($showresult['marital_status'] == 'Married' && $showresult['childern'] != '') { ?>
<dd><strong>Childern : </strong> <?php echo $showresult['childern']; ?></dd>
<?php } ?>
</dl>
</article>
<article>
<h4><strong>Address</strong></h4>
<div class="dropdown-divider"></div>
<div class="row">
<div class="col-md-6">
<dd><strong>Present Address : </strong> <?php echo $showresult['present_address']; ?></dd>
<dd><strong>City : </strong> <?php echo $cityresult['city_name']; ?></dd>
<dd><strong>State / Province : </strong> <?php echo $stateresult['state_name']; ?></dd>
<dd><strong>Postal / Zip Code : </strong> <?php echo $showresult['present_zipcode']; ?></dd>
</div>
<div class="col-md-6">
<dd><strong>Permanent Address : </strong> <?php echo $showresult['permanent_address']; ?></dd>
<dd><strong>City : </strong> <?php echo $pcityresult['city_name']; ?></dd>
<dd><strong>State / Province : </strong> <?php echo $pstateresult['state_name']; ?></dd>
<dd><strong>Postal / Zip Code : </strong> <?php echo $showresult['permanent_zipcode']; ?></dd>
</div>
</div>
</article>
<?php if($checkDoc >0){ ?>
<!-------------->
<article>
<h4><strong>Documents</strong></h4>
<div class="dropdown-divider"></div>
<div class="document_card">
<ul class="attached-document clearfix">
<?php foreach ($employeedocQry as $doc) {
$extension = pathinfo($doc['document'], PATHINFO_EXTENSION);
if ($extension == 'pdf' || $extension == 'PDF') {
$document_type = '<i class="fa fa-file-pdf" style="color:red;"></i>';
} else if ($extension == 'txt' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'png' || $extension == 'webp') {
$document_type = '<i class="fa fa-image" style="color: black;"></i>';
} else if ($extension == 'doc' || $extension == 'docx' || $extension == 'DOCX') {
$document_type = '<i class="fa fa-file-word"></i>';
} else {
$document_type = '<i class="fa fa-folder" style="color:#f0d907;"></i>';
}
?>
<li>
<a href="uploads/<?php echo $doc['document']; ?>" download>
<div class="document-file">
<?php echo $document_type; ?>
</div>
</a>
<div class="document-name"><a href="javascript:;"><?php echo $doc['document_name']; ?></a></div>
</li>
<?php } ?>
</ul>
</div>
<?php if($checkDoc >= 4){ ?>
<div style="text-align: center;">
<a href="employee-document.php?emp=<?php echo $empID; ?>" class="btn btn-primary btn-sm">View More Document</a>
</div>
<?php } ?>
</article>
<!-------------->
<?php } ?>
<?php } ?>