File: /var/www/content-sp/work-sp/nqb_proofread_access_report_oly_exams.php
<?php
include_once('nqb_master_section_oly.php');
// error_reporting(0);
// error_reporting(E_ALL);
// ini_set('display_errors', 'On');
//check edit permissions
$fileName = 'nqb_proofread_exam_wise_oly';
include_once 'pagination.php';
$pagination_link = 'nqb_proofread_access_report_oly_exams';
if (in_array($fileName, $pageArray)) {
$adminId = $editor_id;
$curDate = date('Y-m-d H:i:s');
$TT_EXAM_CATEGORIES_TABLE = 'shineoly_2022.wp_shine_tt_exam_categories';
$SP_MEDIUM = 'contentserver_202130.csp_sp_medium';
$SP_EDITORS = 'contentserver_202130.csp_editors';
$SP_MASTER_PROOF_READ_ACCESS = 'contentserver_202130.csp_proofread_access';
$SP_QUESTION_MEDIUM_WISE = 'contentserver_202130.csp_sp_question_medium_wise';
$SP_QUESTION = 'contentserver_202130.csp_sp_question';
//editors
$editors = $conn->query("SELECT editor_id,contact_name FROM $SP_EDITORS where team_id='3' and editor_status='1' order by editor_id");
/***remove filter */
if (isset($_REQUEST['remove_filter'])) {
unset($_SESSION['olyassign_subQuery']);
unset($_SESSION['olyassign_text']);
}
/**search */
if (isset($_REQUEST['search_data'])) {
$es_editor = $_REQUEST['es_editor'];
$es_ondate = $_REQUEST['es_ondate'];
$es_fromdate = $_REQUEST['es_fromdate'];
$es_todate = $_REQUEST['es_todate'];
$h_assign_to = $_REQUEST['h_assign_to'];
$subQuery = '';
$textF = '';
if ($es_editor != '') {
$subQuery .= "and ac.assign_to='$es_editor' ";
$textF .= "<span class='badge badge-success'>" . $h_assign_to . "</span>";
}
if ($es_ondate != '') {
$q_date = date('Y-m-d', strtotime($es_ondate));
$subQuery .= "and date(ac.assign_date)='$q_date'";
$textF .= "<span class='badge badge-success'>" . date('d M, Y', strtotime($q_date)) . "</span>";
}
if ($es_fromdate != '' && $es_todate != '') {
$fromDate = date('Y-m-d', strtotime($es_fromdate));
$toDate = date('Y-m-d', strtotime($es_todate));
$subQuery .= "and (date(ac.assign_date) BETWEEN '$fromDate' AND '$toDate')";
$textF .= "<span class='badge badge-success'> from " . date('d M, Y', strtotime($fromDate)) . " to " . date('d M, Y', strtotime($toDate)) . "</span>";
}
$_SESSION['olyassign_subQuery'] = $subQuery;
$_SESSION['olyassign_text'] = $textF;
}
if (!empty($_SESSION['olyassign_subQuery'])) {
$mergeFilter = $_SESSION['olyassign_subQuery'];
} else {
$mergeFilter = "";
}
/**
* assign id to new assignee
*/
if (isset($_REQUEST['assign_to_new'])) {
$a_id = $_REQUEST['a_id'];
$as_src = $_REQUEST['as_src'];
$as_tar = $_REQUEST['as_tar'];
$as_assign = $_REQUEST['as_assign'];
if ($a_id != '' && $a_id != '0') {
$ga = $conn->query("SELECT master_type,master_id,subject_id,topic_id,sub_topic_id,ques_type,assign_type,level_status,questions,limit_ques FROM $SP_MASTER_PROOF_READ_ACCESS where id='$a_id'");
$a = $ga->fetch_assoc();
$masterType = $a['master_type'];
$master_id = $a['master_id'];
$subject_id = $a['subject_id'];
$topic_id = $a['topic_id'];
$sub_topic_id = $a['sub_topic_id'];
$ques_type = $a['ques_type'];
$assign_type = $a['assign_type'];
$level_status = $a['level_status'];
$questions = $a['questions'];
$limit_ques = $a['limit_ques'];
$insertQuery = "INSERT into $SP_MASTER_PROOF_READ_ACCESS set master_type='$masterType',master_id='$master_id', subject_id='$subject_id', topic_id='$topic_id', sub_topic_id='$sub_topic_id', medium_id='$as_src', target_medium='$as_tar', ques_type='$ques_type', assign_to='$as_assign', assign_type='$assign_type', level_status='$level_status', status='1', assign_by='$adminId', assign_date='$curDate', questions='$questions', limit_ques='$limit_ques'";
if ($conn->query($insertQuery)) {
$response = "<div class='alert alert-success'>Assigned</div>";
} else {
$response = "<div class='alert alert-danger'>Not Assigned</div>";
}
}
}
/**live query */
include_once '../cron/config.php';
$limit = 100;
$pageNo = isset($_GET['pageN']) ? $_GET['pageN'] : 1;
$indexN = ($pageNo - 1) * $limit;
$countQuery = $live->query("SELECT count(ac.id) as total from $SP_MASTER_PROOF_READ_ACCESS as ac LEFT JOIN $TT_EXAM_CATEGORIES_TABLE as mc ON mc.exam_category_id=ac.master_id LEFT JOIN $TT_EXAM_CATEGORIES_TABLE as s ON s.exam_category_id=ac.subject_id LEFT JOIN $TT_EXAM_CATEGORIES_TABLE as t ON t.exam_category_id=ac.topic_id LEFT JOIN $SP_EDITORS as ta ON ta.editor_id=ac.assign_to LEFT JOIN $SP_EDITORS as tb ON tb.editor_id=ac.assign_by LEFT JOIN $SP_MEDIUM as md ON md.medium_id=ac.medium_id LEFT JOIN $SP_MEDIUM as tmd ON tmd.medium_id=ac.target_medium where ac.status IN('0','1') and ac.assign_type='exam' $mergeFilter");
$cQuery = $countQuery->fetch_assoc();
$count = $cQuery['total'];
$noOfPages = ceil($count / $limit);
$getWorkQuery = "SELECT ac.id,ac.master_id, mc.category_name, ac.subject_id, ac.topic_id, s.category_name as subject, t.category_name as topic, ta.contact_name as tto, tb.contact_name as tby, ac.assign_date, ac.status, ac.medium_id,md.medium_name as source_med,tmd.medium_name as tar_med,ac.target_medium,tmd.medium_code,ac.assign_to,ac.questions,ac.level_status from $SP_MASTER_PROOF_READ_ACCESS as ac LEFT JOIN $TT_EXAM_CATEGORIES_TABLE as mc ON mc.exam_category_id=ac.master_id LEFT JOIN $TT_EXAM_CATEGORIES_TABLE as s ON s.exam_category_id=ac.subject_id LEFT JOIN $TT_EXAM_CATEGORIES_TABLE as t ON t.exam_category_id=ac.topic_id LEFT JOIN $SP_EDITORS as ta ON ta.editor_id=ac.assign_to LEFT JOIN $SP_EDITORS as tb ON tb.editor_id=ac.assign_by LEFT JOIN $SP_MEDIUM as md ON md.medium_id=ac.medium_id LEFT JOIN $SP_MEDIUM as tmd ON tmd.medium_id=ac.target_medium where ac.status IN('0','1') and ac.assign_type='exam' $mergeFilter order by ac.id desc limit $indexN, $limit";
$getWorkData = $live->query($getWorkQuery);
?>
<style>
.form-group select {
height: 34px;
}
.modal-backdrop {
z-index: 999 !important;
}
.radio_ans {
top: -2px;
left: 11px;
height: 15px !important;
width: 25px !important;
background-color: #eee !important;
border-radius: 50%;
position: relative !important;
opacity: 1 !important;
}
select.form-control {
width: 15em !important;
}
table.dataTable {
font-size: 13px;
}
.delWork {
color: red;
font-size: 15px;
cursor: pointer;
margin-left: 4px;
}
.tddd {
cursor: pointer;
}
.fa-share-square-o {
font-size: 20px;
color: #6155e8;
cursor: pointer;
}
.badge-success {
font-weight: bold;
}
</style>
<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
<script src="assets/plugins/jquery/jquery-2.1.3.min.js"></script>
<script src="assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<link href="assets/plugins/datatables/css/jquery.datatables.min.css" rel="stylesheet">
<link href="assets/plugins/datatables/css/responsive.datatables.min.css" rel="stylesheet">
<script src="assets/plugins/datatables/js/jquery.datatables.min.js"></script>
<script src="assets/plugins/datatables/js/jquery.datatables.js"></script>
<script src="assets/plugins/datatables/js/datatables.responsive.min.js"></script>
<link href="assets/plugins/select2/css/select2.min.css" rel="stylesheet">
<script src="assets/plugins/select2/js/select2.min.js"></script>
<script type="text/javascript">
var jq = jQuery.noConflict();
jq(document).ready(function() {
jq('#assign_table').dataTable({
"bPaginate": true,
bFilter: true,
"responsive": true,
"iDisplayLength": 100,
});
jq("#date").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
jq("#todate").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
jq("#fromdate").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
jq('.editors-dropdown').select2();
jq(document).on('change', '#date', function() {
jq("#fromdate").val('');
jq("#todate").val('');
});
jq(document).on('change', '#fromdate', function() {
jq("#date").val('');
});
});
jQuery(document).on('change', '#editor', function() {
var editOr = this.value;
var t1 = jQuery("#editor option[value='" + editOr + "']").text();
jQuery("#assign_to").val(t1);
});
</script>
<div class="row">
<div class="col-md-12">
<?php if (isset($response)) { ?>
<?php echo $response; ?>
<?php } ?>
</div>
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Search Filter</h4>
</div>
<div class="spacer"></div>
<div class="panel-body">
<form class="form-horizontal" method="post" onSubmit="return validateForm();">
<div class="form-group">
<label for="editor" class="col-sm-2">Assign to</label>
<div class="col-sm-10">
<input type="hidden" name="h_assign_to" id="assign_to">
<select name="es_editor" class="form-control editors-dropdown" id="editor">
<option value="">--Editors--</option>
<?php while ($ms = $editors->fetch_assoc()) { ?>
<option value="<?php echo $ms['editor_id']; ?>" <?php if (@$es_editor == $ms['editor_id']) {
echo "selected";
} ?>><?php echo $ms['editor_id'] . '|' . $ms['contact_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group" id="d">
<label for="date" class="col-sm-2">On Date</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="es_ondate" id="date" placeholder="On Date" value="<?php echo @$es_ondate; ?>">
</div>
</div>
<div class="form-group" id="ft">
<label for="date" class="col-sm-2">From/To Date</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="es_fromdate" id="fromdate" placeholder="From Date" value="<?php echo @$es_fromdate; ?>">
</div>
<div class="col-sm-4">
<input type="text" class="form-control" name="es_todate" id="todate" placeholder="To Date" value="<?php echo @$es_todate; ?>">
</div>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Search" name="search_data">
</div>
</form>
<form class="form-horizontal" method="post">
<div class="form-group">
<input type="submit" class="btn btn-danger" value="Reset Filter" name="remove_filter">
</div>
</form>
</div>
</div>
</div>
<div class="col-md-12">
<?php if (isset($_SESSION['olyassign_text'])) { ?>
<div class="panel panel-white">
<div class="panel-heading clearfix">
<h4 class="panel-title"><?php echo 'Filter : ' . $_SESSION['olyassign_text']; ?></h4>
</div>
</div>
<?php } ?>
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Translator Assign Questions</h4>
</div>
<div class="spacer"></div>
<div class="panel-body">
<div class="table-responsive">
<table id="assign_table" class="display table" style="width: 100%; cellspacing: 0;">
<thead>
<tr>
<th>S.no</th>
<th>Id</th>
<th>Status</th>
<th>Assign to other</th>
<th>Exam</th>
<th>Subject</th>
<th>Topic</th>
<th>Source</th>
<th>Target</th>
<th>Total</th>
<th>DoneP</th>
<th>DoneT</th>
<th>To</th>
<th>By</th>
<th>Date</th>
<th>View</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
while ($gwd = $getWorkData->fetch_assoc()) {
if ($gwd['status'] == '0') {
$sts = '<font style="color:red;">DeActive</font>';
} else if ($gwd['status'] == '1') {
$sts = '<font style="color:green;">Active</font>';
}
$assignId = $gwd['id'];
$tpc = $gwd['topic_id'];
$medium = $gwd['medium_id'];
$medium_code = $gwd['medium_code'];
$target_medium = $gwd['target_medium'];
$questions = $gwd['questions'];
$assign_to = $gwd['assign_to'];
$assign_date = date('Y-m-d',strtotime($gwd['assign_date']));
if ($questions != '') {
$level_status = $gwd['level_status'];
if ($level_status == '0') {
$subSt = "and sq.status='4'";
} else {
$subSt = '';
}
$limitQues = sizeof(explode(",", $questions));
// $doneCount = $conn->query("SELECT count(sq.question_id) as doneTot from $SP_QUESTION_MEDIUM_WISE as sq where sq.question_id IN($questions) and medium_id='$target_medium' $subSt");
// $dct = $doneCount->fetch_assoc();
// $doneF = $dct['doneTot'];
$doneCount = $conn->query("SELECT sq.question_id from $SP_QUESTION_MEDIUM_WISE as sq where sq.question_id IN($questions) and sq.status IN('3','4') and medium_id='$target_medium' and (last_proofread_by='$assign_to' OR add_by='$assign_to') and (date(last_proofread_date) >= '$assign_date' OR date(add_date) >= '$assign_date')");
$dct = array();
while($r = $doneCount->fetch_assoc()) {
$dct[] = $r['question_id'];
}
$doneCount2 = $conn->query("SELECT sq.question_id from $SP_QUESTION as sq where sq.question_id IN($questions) and sq.status IN('3','4') and medium_id='$medium' and (last_proofread_by='$assign_to' OR add_by='$assign_to') and (date(last_proofread_date) >= '$assign_date' OR date(add_date) >= '$assign_date')");
$dct2 = array();
while($r2 = $doneCount2->fetch_assoc()) {
$dct2[] = $r2['question_id'];
}
$merge = array_unique(array_merge($dct,$dct2));
// print_r($merge);
$doneF = count($merge);
// echo $assignId;
// echo "<br>";
// print_r($dct);
// echo "<br>";
// print_r($dct2);
/***translate count */
$doneCountAdd = $conn->query("SELECT count(sq.question_id) as add_trans from $SP_QUESTION_MEDIUM_WISE as sq where sq.question_id IN($questions) and sq.status NOT IN('3','4') and medium_id='$target_medium' and (last_proofread_by='$assign_to' OR add_by='$assign_to') and (date(last_proofread_date) >= '$assign_date' OR date(add_date) >= '$assign_date')");
$addT = $doneCountAdd->fetch_assoc();
$doneCOuntTrans = $addT['add_trans'];
} else {
$limitQues = '--';
$doneF = '--';
$doneCOuntTrans = '---';
}
?>
<tr>
<td><?php echo $i + $indexN; ?></td>
<td><?php echo $gwd['id']; ?></td>
<td id="td_<?php echo $gwd['id']; ?>">
<font id="fnt_<?php echo $gwd['id']; ?>" class="tddd"><?php echo $sts; ?></font><i class="fa fa-trash delWork" id="ico_<?php echo $gwd['id']; ?>"></i>
</td>
<td>
<i data-toggle="modal" data-target="#assIgn" class="fa fa-share-square-o" onclick="assignToOther('<?php echo $assignId; ?>')"></i>
</td>
<td><?php echo $gwd['category_name']; ?></td>
<td><?php echo $gwd['subject']; ?></td>
<td><?php echo $gwd['topic']; ?></td>
<td><?php echo $gwd['source_med']; ?></td>
<td><?php echo $gwd['tar_med']; ?></td>
<td><?php echo $limitQues; ?></td>
<td><?php echo $doneF; ?></td>
<td><?php echo $doneCOuntTrans; ?></td>
<td><?php echo $gwd['tto']; ?></td>
<td><?php echo $gwd['tby']; ?></td>
<td><?php echo date('d-m-Y', strtotime($gwd['assign_date'])); ?></td>
<td><a target="_blank" href="nqb_proofread_oly_ques_view.php?uniqueID=<?php echo $gwd['id']; ?>">User View</a></td>
</tr>
<?php $i++;
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<?php echo pagination($limit, $pageNo, $pagination_link . "?pageN=", $count); ?>
</div>
<!-----Assign Modal------>
<div id="assIgn" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="padding: 5px 10px 0px 0px; height: 20px;">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body" id="modal_body1">
</div>
</div>
</div>
</div>
<!-----Assign Modal End------>
</div>
<div class="page-footer">
<p class="no-s">Graposs Connect ©</p>
</div>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('.tddd').on('click', function() {
var idd = this.id;
var wid = idd.substring(4);
var loadUrl = "ajax_call/nqb_proofread_access_update.php?wid=" + wid + "&typ=upd";
var jqxhr = jQuery.get(loadUrl);
jqxhr.success(function(data) {
jQuery("#fnt_" + wid).html(data);
});
});
jQuery(document).on('click', '.delWork', function() {
var idd = this.id;
var wid = idd.substring(4);
var loadUrl = "ajax_call/nqb_proofread_access_update.php?wid=" + wid + "&typ=del";
var jqxhr = jQuery.get(loadUrl);
jqxhr.success(function(data) {
jQuery("#td_" + wid).html(data);
});
});
});
/**
* assign to other assignee
*/
function assignToOther(a_id) {
var site = "ajax_call/nqb_assign_to_other.php?a_id=" + a_id;
jQuery.ajax({
url: site,
type: 'POST',
data: 'html',
success: function(data) {
document.getElementById("modal_body1").innerHTML = data;
enableSelect2();
}
});
}
</script>
<?php
} else {
echo "<script type='text/javascript'>alert('You dont have access to view this report');</script>";
echo "<script type='text/javascript'>location.href='/work-sp';</script>";
}
include_once('footer.php');
?>