File: /var/www/nclive/technc/nc_exam_tracker_list.php
<?php include 'header.php';
$getUsers="Select id, username from sp_admin_login where status='1'";
$allUsers = $db->prepare($getUsers);
$allUsers->execute();
//$subquery = 1;
if(isset($_REQUEST['submit']))
{
if(isset($_REQUEST['search_type']))
{
$search_type = $_REQUEST['search_type'];
$search_base = $_REQUEST['search_base'];
$user = $_REQUEST['user'];
$date = date('Y-m-d',strtotime($_REQUEST['ondate']));
if($search_type=='1')
{
if($_REQUEST['search_base']=='1' && $user!='U')
{
$subquery = "where date(e.add_date)='$date' and e.add_by='$user'";
}
else if($_REQUEST['search_base']=='1' && $user=='U')
{
$subquery = "where date(e.add_date)='$date'";
}
else if($_REQUEST['search_base']=='2' && $user!='U')
{
$subquery = "where date(e.update_date)='$date' and e.update_by='$user'";
}
else if($_REQUEST['search_base']=='2' && $user=='U')
{
$subquery = "where date(e.update_date)='$date'";
}
else
{
$subquery = "";
}
}
else if($search_type=='2')
{
$user = $_REQUEST['user'];
$fromdate = date('Y-m-d',strtotime($_REQUEST['fromdate']));
$todate = date('Y-m-d',strtotime($_REQUEST['todate']));
if($_REQUEST['search_base']=='1' && $user!='U')
{
$subquery = "where date(e.add_date) >='$fromdate' AND date(e.add_date) <= '$todate' and e.add_by='$user'";
}
else if($_REQUEST['search_base']=='1' && $user=='U')
{
$subquery = "where date(e.add_date) >='$fromdate' AND date(e.add_date) <= '$todate'";
}
else if($_REQUEST['search_base']=='2' && $user!='U')
{
$subquery = "where date(e.update_date) >='$fromdate' AND date(e.update_date) <= '$todate' and e.update_by='$user'";
}
else if($_REQUEST['search_base']=='2' && $user=='U')
{
$subquery = "where date(e.update_date)='$date'";
}
else
{
$subquery = "";
}
}
else if($search_type=='3')
{
$user = $_REQUEST['user'];
if($_REQUEST['search_base']=='1' && $user!='U')
{
$subquery = "where e.add_by='$user'";
}
else if($_REQUEST['search_base']=='2' && $user!='U')
{
$subquery = "where e.update_by='$user'";
}
else
{
$subquery = "";
}
}
}
}
$getExamQuery = "Select e.exam_id,e.exam_name, e.status, e.add_by, e.add_date, e.off_web_link, al.username from sp_exam as e left join sp_admin_login as al on al.id=e.add_by $subquery order by e.add_date desc ";
$getData=$db->prepare($getExamQuery);
$getData->execute();
?>
<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script>
jQuery.noConflict();
jQuery(function($) {
jQuery('#examData').dataTable({
"bPaginate": true,
bFilter:true,
"responsive": true,
"lengthMenu": [[50, 100, 150, 200, 1000], [50, 100, 150, 200, 1000]],
});
});
</script>
<main id="main-container">
<div class="content content-narrow">
<div class="row">
<div class="col-lg-12">
<div class="block">
<div class="block-header" style="background: #663399c7;color: #fff;">
Filter By :)
</div>
<div class="block-content block-content-narrow">
<form class="js-validation-bootstrap form-inline" method="post">
<div class="form-group">
<label>Search Base :</label>
<select class="js-select2 form-control" name="search_base">
<option value="0">--Search on Basis--</option>
<option value="1">Add Date</option>
<option value="2">Update Date</option>
</select>
</div>
<div class="form-group">
<label><input type="radio" name="search_type" value="3"> Select Editor :</label>
<select class="js-select2 form-control" name="user">
<option value="U">--Select Editor--</option>
<?php while($user=$allUsers->fetch()){ ?>
<option value="<?php echo $user['id']; ?>"><?php echo $user['username']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label><input type="radio" name="search_type" value="1"> On Date :</label>
<input class="form-control" type="date" name="ondate" value="" placeholder="On Date">
</div>
<br><br>
<div class="form-group">
<label><input type="radio" name="search_type" value="2"> Between Date :</label>
<input class="form-control" type="date" name="fromdate" value="">
<input class="form-control" type="date" name="todate" value="">
</div>
<div class="form-group">
<button class="btn btn-sm btn-primary" type="submit" name="submit">Submit</button>
</div>
</form>
</div>
<br><br>
</div>
</div>
<div class="col-lg-12">
<h2 class="content-heading" style="background: #663399c7;color: #fff;padding: 16px 1px 20px 15px;">Exam List</h2>
<div class="table-responsive">
<table id="examData" class="table table-striped table-bordered dt-responsive nowrap" style="width: 100%;cellspacing:0;">
<thead>
<tr>
<th>S.no</th>
<th>Exam Name</th>
<th>Entity </th>
<th title="Official website">Off. Web</th>
<th>Status</th>
<th>Add By</th>
<th>Add Date</th>
</tr>
</thead>
<tbody>
<?php $i =1; while($data = $getData->fetch())
{
$examid = $data['exam_id'];
$getEntities="Select el.id,el.entity_id,ee.name,el.date_type,el.date from sp_exam_links as el left join sp_exam_entity as ee on ee.id=el.entity_id where el.exam_id='$examid' order by el.add_date asc";
$entity=$db->prepare($getEntities);
$entity->execute();
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $data['exam_name']; ?></td>
<td>
<table class="table table-striped table-bordered dt-responsive nowrap">
<?php while($row=$entity->fetch())
{
$dateType = $row['date_type'];
$curDate = date('Y-m-d');
$date = $row['date'];
if($dateType=='N')
{
$Ndate = $date;
if($curDate<$Ndate)
{
$color = "#ff000047";
}
else
{
$color = "";
}
}
else if($dateType=='FT')
{
$dateArray = explode(",",$date);
$date1 = date('Y-m-d',strtotime($dateArray[0]));
$date2 = date('Y-m-d',strtotime($dateArray[1]));
if($curDate<$date1)
{
$color = "#ff000047";
}
else
{
$color = "";
}
}
?>
<tr>
<td style="border-top: 2px solid #ddd;padding: 7px 0px 7px 10px !important;background: <?php echo $color; ?>"><?php echo $row['name']; ?></td>
<td style="border-top: 2px solid #ddd;padding: 7px 0px 7px 10px !important;background: <?php echo $color; ?>"><i class="fa fa-plus-circle" style="cursor:pointer;color: #31b131;font-size: x-large;" onclick="entityCheck(<?php echo $row['id']; ?>)" data-toggle="modal" data-target="#entityCheck"></i></td>
</tr>
<?php } ?>
</table>
</td>
<td><?php echo $data['off_web_link']; ?></td>
<td><?php echo $data['status']; ?></td>
<td><?php echo $data['username']; ?></td>
<td><?php echo $data['add_date']; ?></td>
</tr>
<?php $i++; } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!--entity modal--->
<div class=" modal fade" id="entityCheck" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Details of this Entity :)</h4>
</div>
<div class="modal-body">
<form class="js-validation-bootstrap form-horizontal" method="post" id="form">
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Display Text</label>
<div class="col-md-10">
<input class="form-control" type="text" name="dis_text" placeholder="" id="dis_text">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Link</label>
<div class="col-md-10">
<input class="form-control" type="text" name="link" placeholder="" id="link">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">On Date<span class="text-danger">*</span></label>
<div class="col-md-1">
<input type="radio" name="search_type" class="radio" value="N" id="N" />
</div>
<div class="col-md-5" id="normal">
<input type="text" class="dates_opted dates_opted_1 width_100" name="normal" id="nor" style="width:400px">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">From & To Date<span class="text-danger">*</span></label>
<div class="col-md-1" >
<input type="radio" name="search_type" value="FT" class="radio" id="FT" />
</div>
<div class="col-md-5" id="fromto">
<input class="form-control" type="text" name="fromdate" placeholder="" id="fromdate">
<input class="form-control" type="text" name="todate" placeholder="" id="todate">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Add By</label>
<div class="col-md-10">
<input class="form-control" type="text" placeholder="" id="add_by">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Add Date</label>
<div class="col-md-10">
<input class="form-control" type="text" placeholder="" id="add_date">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Update By</label>
<div class="col-md-10">
<input class="form-control" type="text" placeholder="" id="update_by">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Update Date</label>
<div class="col-md-10">
<input class="form-control" type="text" placeholder="" id="update_date">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!--entity modal end--->
<script>
function entityCheck(id)
{
var site = "/technc/nc_exam_tracker_exam_entity.php?entity="+id;
jQuery.ajax({
url: site,
type:'POST',
data:'html',
success:function(data){
document.getElementById("dis_text").value = data.display_text;
document.getElementById("link").value = data.links;
document.getElementById("add_by").value = data.addBy;
document.getElementById("add_date").value = data.add_date;
document.getElementById("update_by").value = data.updateBy;
document.getElementById("update_date").value = data.update_date;
var c='';
var date=data.date;
if(data.date_type == 'N')
{
document.getElementById('nor').value = date;
document.getElementById('fromdate').value = c;
document.getElementById('todate').value = c;
// $("#normal").css('display','block');
// $("#fromto").css('display','none');
$("#N").attr('checked','checked');
}
else if(data.date_type == 'FT')
{
var date=data.date;
var d = date.split(",");
var myd= d[0] + ',' + d[1];
document.getElementById('fromdate').value = d[0];
document.getElementById('todate').value = d[1];
document.getElementById('nor').value = c;
// $("#fromto").css('display','block');
// $("#normal").css('display','none');
$("#FT").attr('checked','checked');
}
}
});
}
</script>
<?php include 'footer.php'; ?>