<?php
$table_name = 'questions';
$redirection_page = "index.php?action=$page_name";
$action_name = "action=$page_name";
$type = $_REQUEST['type'];
$edit_id = $_REQUEST['edit_id'];
$delete_id = $_REQUEST['delete_id'];
$forward_id = $_REQUEST['forward_id'];
if (isset($_POST['submit'])) {
$question_id = $_POST['question_id'];
$expert_name = $_POST['expert_name'];
$insert_bookings32 = "UPDATE `questions` SET
expert_id = '" . addslashes($expert_name) . "',
status = 'Assigned To Expert'
where id='" . $question_id . "'";
$sql_insert32 = $dbconn->prepare($insert_bookings32);
$sql_insert32->execute();
$message = "Question transfered successfully.";
$status = "success";
}
// For Displaying the table
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 7;
$offset = ($pageno - 1) * $no_of_records_per_page;
$select_enquiry = "SELECT * FROM $table_name where status = 'Active' order by id desc";
$sql = $dbconn->prepare($select_enquiry);
$sql->execute();
$total_rows = $sql->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);
$select_enquiry = "SELECT * FROM $table_name where status = 'Assigned To Sub-Admin' AND sub_admin_id = $master_user_id order by id desc LIMIT $offset, $no_of_records_per_page";
$sql = $dbconn->prepare($select_enquiry);
$sql->execute();
$wlvd = $sql->fetchAll(PDO::FETCH_OBJ);
$select_bookings = "SELECT * FROM `$table_name`";
$sql1 = $dbconn->prepare($select_bookings);
$sql1->execute();
$wlvd1 = $sql1->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd1 as $rows1);
?>
<div class="container-fluid">
<div class="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumb-->
<div class="row pt-2 pb-2">
<div class="col-sm-9">
<h4 class="page-title"><?php echo $page_name; ?></h4>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.php?action=Welcome">Dashboard</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="index.php?action=<?php echo $page_name; ?>"><?php echo $page_name; ?></a></li>
</ol>
</div>
<div class="col-sm-3">
<?php include('plugins/alert.php'); ?>
<!-- Button trigger modal -->
</div>
</div>
<!-- End Breadcrumb-->
<?php if ($type == 'Delete') {
$delete_statement = "UPDATE `$table_name` SET
status = 'Inactive'
where id='" . $delete_id . "'";
$sql_insert = $dbconn->prepare($delete_statement);
$sql_insert->execute();
$message = "Details successfully updated.";
$status = "success";
header("Location: $redirection_page&id=$delete_id");
} else {
?>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header"><i class="fa fa-user"></i> All Records</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover" id="sample-table-1">
<thead class="thead-dark">
<tr>
<th class="center"> ID</th>
<th class="center"> Question Category</th>
<th class="center"> Question Sub-Category</th>
<th class="center"> Question Question Description</th>
<th class="center"> Status</th>
<th class="center"> Action</th>
</tr>
</thead>
<tbody>
<?php
//while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
//{
if ($sql->rowCount() > 0) {
foreach ($wlvd as $rows) {
$field1 = $rows->id;
$field2 = $rows->question_cat;
$field3 = $rows->question_subcat;
$field4 = $rows->question_question_description;
$field5 = $rows->status;
?>
<tr>
<td class="center"><?php echo $field1; ?></td>
<td class="center"><?php echo $field2; ?></td>
<td class="center"><?php echo $field3; ?></td>
<td class="center"><?php echo $field4; ?></td>
<td class="center"><?php echo $field5; ?></td>
<td class="center">
<a href="index.php?action=sub-admin-reply&edit_id=<?php echo $field1; ?>" target="_self"><i class="fa fa-reply"></i> Reply</a>
<a href="<?php echo $redirection_page; ?>&forward_id=<?php echo $field1; ?>&type=Forward" target="_self" data-toggle="modal" data-target="#forwardModal_<?php echo $field1; ?>"><i class="fa fa-arrow-circle-right"></i> Forward</a>
<a href="javascript:void(0);" onclick="confirmDelete(<?php echo $field1; ?>)"><i class="fa fa-trash"></i> Delete</a>
<style>
/* smooth transition to the modal */
.modal.fade .modal-dialog {
transition: transform 0.7s ease-in-out, opacity 0.8s ease;
}
.modal.fade.show .modal-dialog {
transform: translate(0, 0);
opacity: 1;
box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.9);
}
</style>
<div class="container-fluid">
<!-- Modal -->
<div class="modal fade" id="forwardModal_<?php echo $field1; ?>" tabindex="-1" role="dialog" aria-labelledby="forwardModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="forwardModalLabel">Forward Question to</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php
echo $forward_id;
?>
<form method="POST" action="">
<div class="form-group">
<label for="subadmin_id">Assign to Expert:</label>
<select class="form-control" id="expert_id" name="expert_name">
<?php
$select_expert = "SELECT * FROM `users` WHERE user_role = 'Expert' AND user_parent_id = '$master_user_id' AND status = 'Active'";
$sql_expert = $dbconn->prepare($select_expert);
$sql_expert->execute();
$experts = $sql_expert->fetchAll(PDO::FETCH_OBJ);
foreach ($experts as $expert) {
$expert_id = $expert->id;
// $parent_id = $expert->user_parent_id;
$expert_name = $expert->user_name;
?>
<option value="<?php echo $expert_id; ?>"><?php echo $expert_name; ?></option>
<?php
}
?>
</select>
</div>
<input type="hidden" name="question_id" value="<?php echo $field1 ?>">
</div>
<div class="modal-footer">
<button name="submit" class="btn btn-primary"> Submit</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
<?php include('plugins/pagination.php'); ?>
</div>
</div>
</div>
</div>
</div>
<?php
};
?>
</div><!-- End Row-->
</div><!--End content-wrapper-->
<!--Start Back To Top Button-->
<a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
<!--End Back To Top Button-->
<script>
function confirmDelete(id) {
if (confirm("Are you sure you want to delete this record?")) {
window.location.href = "index.php?action=<?php echo $page_name; ?>&delete_id=" + id + "&type=Delete";
}
}
</script>