HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/content-sp/work-sp/nqb_proofreader_dashboard.php
<?php
include_once('header.php');
// error_reporting(0);
// error_reporting(E_ALL);
// ini_set('display_errors', 'On');
$adminId = $editor_id;
$curDate = date('Y-m-d H:i:s');
$toDate = date('Y-m-d');

//check edit permissions
$fileName = str_replace('.php', '', basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']));
if (in_array($fileName, $pageArray)) {
    $SP_MASTER_CATEGORY = 'csp_sp_master_category';
    $SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
    $SP_QUES_HISTORY = 'csp_sp_question_history';
    $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';
    $TT_EXAM_CATEGORIES_TABLE = 'cscolydb.wp_aat93akkcv_tt_exam_categories';
    $SP_QUESTION = 'csp_sp_question';

    //$SP_MASTER_PROOF_READ_REVERT = $wpdb->prefix . SP_MASTER_PROOF_READ_REVERT;

    /***master questions */
    $getWorkQuery = "SELECT ac.id,ac.master_type, mc.master_name,ac.master_id, ac.subject_id, ac.topic_id, ac.sub_topic_id, s.category_name as subject, t.category_name as topic, st.category_name as subtopic, 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_code,tmd.medium_name as tar_med,ac.target_medium, ac.assign_to,ac.questions,ac.level_status from $SP_MASTER_PROOF_READ_ACCESS as ac LEFT JOIN $SP_MASTER_CATEGORY as mc ON mc.master_id=ac.master_id LEFT JOIN $SP_MASTER_STRUCTURE as s ON s.sub_id=ac.subject_id LEFT JOIN $SP_MASTER_STRUCTURE as t ON t.sub_id=ac.topic_id LEFT JOIN $SP_MASTER_STRUCTURE as st ON st.sub_id=ac.sub_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='1' and ac.assign_to='$adminId' and ac.assign_type='master' order by ac.id asc";
    $getWorkData = $conn->query($getWorkQuery);
    $ifData = mysqli_num_rows($getWorkData);

    /**live query oly questions */
    include_once '../cron/config.php';
    $getWorkQueryolyExams = "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='1' and ac.assign_to='$adminId' and ac.assign_type='exam' order by ac.id desc";
    $getWorkDataOly = $live->query($getWorkQueryolyExams);
    $ifOlyData = mysqli_num_rows($getWorkDataOly);

    /***previous year question proofread */
    $getPrevQuery = "SELECT ac.id, 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_code,tmd.medium_name as tar_med,ac.target_medium, ac.assign_to,ac.questions,ac.level_status from $SP_MASTER_PROOF_READ_ACCESS as ac 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='1' and ac.assign_to='$adminId' and ac.assign_type='previous' order by ac.id asc";
    $getPrevData = $conn->query($getPrevQuery);
    $ifPrevData = mysqli_num_rows($getPrevData);

    /***date wise question proofread */
    $getDWQuery = "SELECT ac.id, 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_code,tmd.medium_name as tar_med,ac.target_medium, ac.assign_to,ac.questions,ac.level_status from $SP_MASTER_PROOF_READ_ACCESS as ac 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='1' and ac.assign_to='$adminId' and ac.assign_type='datewise' order by ac.id asc";
    $getDWData = $conn->query($getDWQuery);
    $ifDWData = mysqli_num_rows($getDWData);


    $getStatusQuery = "SELECT count(case when date(action_date)='$toDate' then 1 end) as dtQues, count(case when question_id!='' then 1 end) as ttQues from $SP_QUES_HISTORY where action_by='$adminId' and action IN(3,4)";
    $getStatusData = $conn->query($getStatusQuery);
    $fHistory = $getStatusData->fetch_assoc();

    // $getRevertQuery = "SELECT count(question_id) as cntQ, confirm_status, confirm_date, approve_status, revert_date from $SP_MASTER_PROOF_READ_REVERT where assignee='$adminId' and approve_status='0' group by date(revert_date) order by date(revert_date)";
    // $getRevertData = $conn->query($getRevertQuery);

?>

    <style>
        table.display {
            font-size: 13px;
        }
    </style>
    <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>
    <script type="text/javascript">
        jQuery.noConflict();
        jQuery(function($) {
            $('#assign_table_sp_oly').dataTable({
                "bPaginate": true,
                bFilter: true,
                "responsive": true,
                "iDisplayLength": 100,
                "order": [
                    [0, 'desc']
                ]
            });
            $('#assign_table_olyExam').dataTable({
                "bPaginate": true,
                bFilter: true,
                "responsive": true,
                "iDisplayLength": 100,
                "order": [
                    [0, 'desc']
                ]
            });
            $('#assign_table_prevExam').dataTable({
                "bPaginate": true,
                bFilter: true,
                "responsive": true,
                "iDisplayLength": 100,
                "order": [
                    [0, 'desc']
                ]
            });
            $('#assign_table_dateW').dataTable({
                "bPaginate": true,
                bFilter: true,
                "responsive": true,
                "iDisplayLength": 100,
                "order": [
                    [0, 'desc']
                ]
            });
        });
    </script>
    <div class="page-inner">
        <div class="page-title">
            <h3>Dashboard</h3>
        </div>
        <div id="main-wrapper">
            <div class="row">
                <!--<div class="col-lg-3 col-md-6">
                            <div class="panel info-box panel-white">
                                <div class="panel-body">
                                    <div class="info-box-stats">
                                        <p class="counters"><?php echo $fHistory['ttQues']; ?></p>
                                        <span class="info-box-title">Total Question Proof Read</span>
                                    </div>
                                </div>
                            </div>
                        </div>-->
                <div class="col-lg-3 col-md-6">
                    <div class="panel info-box panel-white">
                        <div class="panel-body">
                            <div class="info-box-stats">
                                <p class="counters"><?php echo $fHistory['dtQues']; ?></p>
                                <span class="info-box-title">Today's Proof Read</span>

                            </div>
                            <div class="info-box-stats" style="font-size: 4em; text-align: center; width: 40%; float: left;">
                                <a href="javascript:void(0);">
                                    <i class="fa fa-eye"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>

            </div><!-- Row -->
            <?php if ($ifData > 0) { ?>
                <div class="col-md-12">
                    <div class="panel panel-info">
                        <div class="panel-heading clearfix">
                            <h4 class="panel-title">List Assigned Topicss (Master)</h4>
                        </div>
                        <div class="spacer"></div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table id="assign_table_sp_oly" class="display table" style="width: 100%; cellspacing: 0;">
                                    <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>Status</th>
                                            <th>Master</th>
                                            <th>Subject</th>
                                            <th>Topic</th>
                                            <th>SubTopic</th>
                                            <th>Source</th>
                                            <th>Target</th>
                                            <th>To</th>
                                            <th>By</th>
                                            <th>Date</th>
                                            <th title="Total Question">TQ</th>
                                            <th title="ProofRead Question">Done</th>
                                            <th>View</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        while ($gwd = $getWorkData->fetch_assoc()) {
                                            if ($gwd['status'] == '1') {
                                                $sts = '<font style="color:green;">Active</font>';
                                            }
                                            $subTpc = $gwd['sub_topic_id'];
                                            $tpc = $gwd['topic_id'];
                                            $medium = $gwd['medium_id'];
                                            $sou_med = $gwd['source_med'];
                                            $tar_med = $gwd['tar_med'];
                                            $target_medium = $gwd['target_medium'];
                                            $assign_to = $gwd['assign_to'];
                                            $assign_date = date('Y-m-d',strtotime($gwd['assign_date']));
                                            $questions = $gwd['questions'];
                                            if ($questions != '') {
                                                $level_status = $gwd['level_status'];
                                                if ($level_status == '0') {
                                                    $subSt = "and sq.status IN('3','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 count(sq.question_id) as doneTot from $SP_QUESTION_MEDIUM_WISE as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct = $doneCount->fetch_assoc();
                                                $doneF1 = $dct['doneTot'];
                                                $doneCount2 = $conn->query("SELECT count(sq.question_id) as doneTot from $SP_QUESTION as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct2 = $doneCount2->fetch_assoc();
                                                $doneF2 = $dct2['doneTot'];
                                                $doneF = $doneF1 + $doneF2;
                                                /******* */

                                            } else {
                                                $limitQues = '--';
                                                $doneF = '--';
                                            }
                                        ?>
                                            <tr>
                                                <td><?php echo $gwd['id']; ?></td>
                                                <td><?php echo $sts; ?></td>
                                                <td><?php echo $gwd['master_name']; ?></td>
                                                <td><?php echo $gwd['subject']; ?></td>
                                                <td><?php echo $gwd['topic']; ?></td>
                                                <td><?php echo $gwd['subtopic']; ?></td>
                                                <td><?php echo $sou_med; ?></td>
                                                <td><?php echo $tar_med; ?></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><?php echo $limitQues; ?></td>
                                                <td><?php echo $doneF; ?></td>
                                                <td><a target="_blank" href="nqb_proofread_ques_view.php?uniqueID=<?php echo $gwd['id']; ?>&master_id=<?php echo $gwd['master_id']; ?>&subject_id=<?php echo $gwd['subject_id']; ?>&topic_id=<?php echo $tpc; ?>&sub_topic_id=<?php echo $subTpc; ?>&viewIn=<?php echo $gwd['medium_code']; ?>&mType=<?php echo $gwd['master_type']; ?>">User View</a></td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>
            <?php if ($ifOlyData > 0) { ?>
                <div class="col-md-12">
                    <div class="panel panel-info">
                        <div class="panel-heading clearfix">
                            <h4 class="panel-title">List Assigned Topics (Olympiad Exams)</h4>
                        </div>
                        <div class="spacer"></div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table id="assign_table_olyExam" class="display table" style="width: 100%; cellspacing: 0;">
                                    <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>Status</th>
                                            <th>Exam</th>
                                            <th>Subject</th>
                                            <th>Topic</th>
                                            <th>Source</th>
                                            <th>Target</th>
                                            <th>To</th>
                                            <th>By</th>
                                            <th>Date</th>
                                            <th>Total</th>
                                            <th>Done</th>
                                            <th>View</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $i = 1;
                                        while ($gwd = $getWorkDataOly->fetch_assoc()) {
                                            if ($gwd['status'] == '1') {
                                                $sts = '<font style="color:green;">Active</font>';
                                            }
                                            $tpc = $gwd['topic_id'];
                                            $medium = $gwd['medium_id'];
                                            $medium_code = $gwd['medium_code'];
                                            $target_medium = $gwd['target_medium'];
                                            $assign_to = $gwd['assign_to'];
                                            $assign_date = date('Y-m-d',strtotime($gwd['assign_date']));
                                            $questions = $gwd['questions'];
                                            if ($questions != '') {
                                                $level_status = $gwd['level_status'];
                                                if ($level_status == '0') {
                                                    $subSt = "and sq.status IN('3','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 count(sq.question_id) as doneTot from $SP_QUESTION_MEDIUM_WISE as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct = $doneCount->fetch_assoc();
                                                $doneF1 = $dct['doneTot'];
                                                $doneCount2 = $conn->query("SELECT count(sq.question_id) as doneTot from $SP_QUESTION as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct2 = $doneCount2->fetch_assoc();
                                                $doneF2 = $dct2['doneTot'];
                                                $doneF = $doneF1 + $doneF2;
                                                /******* */

                                            } else {
                                                $limitQues = '--';
                                                $doneF = '--';
                                            }



                                        ?>
                                            <tr>
                                                <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>
                                                </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 $gwd['tto']; ?></td>
                                                <td><?php echo $gwd['tby']; ?></td>
                                                <td><?php echo date('d-m-Y', strtotime($gwd['assign_date'])); ?></td>
                                                <td><?php echo $limitQues; ?></td>
                                                <td><?php echo $doneF; ?></td>
                                                <td><a target="_blank" href="nqb_proofread_oly_ques_view.php?uniqueID=<?php echo $gwd['id']; ?>">User View</a></td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>
            <?php if ($ifPrevData > 0) { ?>
                <div class="col-md-12">
                    <div class="panel panel-info">
                        <div class="panel-heading clearfix">
                            <h4 class="panel-title">List Assigned Topics (Previous Year Exams)</h4>
                        </div>
                        <div class="spacer"></div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table id="assign_table_prevExam" class="display table" style="width: 100%; cellspacing: 0;">
                                    <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>Status</th>
                                            <th>Previous Exam</th>
                                            <th>Previous Year</th>
                                            <th>Source</th>
                                            <th>Target</th>
                                            <th>To</th>
                                            <th>By</th>
                                            <th>Date</th>
                                            <th>Total</th>
                                            <th>Done</th>
                                            <th>View</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $i = 1;
                                        while ($gwd = $getPrevData->fetch_assoc()) {
                                            if ($gwd['status'] == '1') {
                                                $sts = '<font style="color:green;">Active</font>';
                                            }

                                            $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']));
                                            $prevDetails = $conn->query("SELECT previous_exam_name,previous_exam_year FROM $SP_QUESTION where question_id IN($questions) group by previous_exam_name,previous_exam_year");
                                            $pvData = $prevDetails->fetch_assoc();
                                            if ($questions != '') {
                                                $level_status = $gwd['level_status'];
                                                if ($level_status == '0') {
                                                    $subSt = "and sq.status IN('3','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 count(sq.question_id) as doneTot from $SP_QUESTION_MEDIUM_WISE as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct = $doneCount->fetch_assoc();
                                                $doneF1 = $dct['doneTot'];
                                                $doneCount2 = $conn->query("SELECT count(sq.question_id) as doneTot from $SP_QUESTION as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct2 = $doneCount2->fetch_assoc();
                                                $doneF2 = $dct2['doneTot'];
                                                $doneF = $doneF1 + $doneF2;
                                                /******* */
                                            } else {
                                                $limitQues = '--';
                                                $doneF = '--';
                                            }
                                        ?>
                                            <tr>
                                                <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>
                                                </td>
                                                <td><?php echo $pvData['previous_exam_name'] ?></td>
                                                <td><?php echo $pvData['previous_exam_year'] ?></td>
                                                <td><?php echo $gwd['source_med']; ?></td>
                                                <td><?php echo $gwd['tar_med']; ?></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><?php echo $limitQues; ?></td>
                                                <td><?php echo $doneF; ?></td>
                                                <td><a target="_blank" href="nqb_proofread_previous_ques_view.php?uniqueID=<?php echo $gwd['id']; ?>">User View</a></td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>
            <?php if ($ifDWData > 0) { ?>
                <div class="col-md-12">
                    <div class="panel panel-info">
                        <div class="panel-heading clearfix">
                            <h4 class="panel-title">List Assigned Topics (Date Wise)</h4>
                        </div>
                        <div class="spacer"></div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table id="assign_table_dateW" class="display table" style="width: 100%; cellspacing: 0;">
                                    <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>Status</th>
                                            <th>Date Wise(add on date)</th>
                                            <th>Source</th>
                                            <th>Target</th>
                                            <th>To</th>
                                            <th>By</th>
                                            <th>Date</th>
                                            <th>Total</th>
                                            <th>Done</th>
                                            <th>View</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $i = 1;
                                        while ($gwd = $getDWData->fetch_assoc()) {
                                            if ($gwd['status'] == '1') {
                                                $sts = '<font style="color:green;">Active</font>';
                                            }

                                            $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']));
                                            $dateDetails = $conn->query("SELECT add_date FROM $SP_QUESTION where question_id IN($questions)");
                                            $dateData = $dateDetails->fetch_assoc();
                                            if ($questions != '') {
                                                $level_status = $gwd['level_status'];
                                                if ($level_status == '0') {
                                                    $subSt = "and sq.status IN('3','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 count(sq.question_id) as doneTot from $SP_QUESTION_MEDIUM_WISE as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct = $doneCount->fetch_assoc();
                                                $doneF1 = $dct['doneTot'];
                                                $doneCount2 = $conn->query("SELECT count(sq.question_id) as doneTot from $SP_QUESTION as sq where sq.question_id IN($questions) 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') $subSt");
                                                $dct2 = $doneCount2->fetch_assoc();
                                                $doneF2 = $dct2['doneTot'];
                                                $doneF = $doneF1 + $doneF2;
                                                /******* */

                                            } else {
                                                $limitQues = '--';
                                                $doneF = '--';
                                            }
                                        ?>
                                            <tr>
                                                <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>
                                                </td>
                                                <td><?php echo date('d-m-Y',strtotime($dateData['add_date'])); ?></td>
                                                <td><?php echo $gwd['source_med']; ?></td>
                                                <td><?php echo $gwd['tar_med']; ?></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><?php echo $limitQues; ?></td>
                                                <td><?php echo $doneF; ?></td>
                                                <td><a target="_blank" href="nqb_proofread_datewise_ques_view.php?uniqueID=<?php echo $gwd['id']; ?>">User View</a></td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>

        </div><!-- Main Wrapper -->
        <div class="page-footer">
        <p class="no-s">Graposs Connect &#169;</p>
        </div>
    </div><!-- Page Inner -->

    <script type="text/javascript">
        jQuery.noConflict();

        function updateSt(uid, datee, typ) {
            var loadUrl = "proofread_question_reverted_update.php?uid=" + uid + "&datee=" + datee + "&typ=" + typ;
            var jqxhr = jQuery.get(loadUrl);
            jqxhr.success(function(data) {
                alert(data);
            });
        }
        jQuery(document).ready(function() {
            //
        });
    </script>
<?php
} else {
    echo "<script type='text/javascript'>alert('You dont have access of proofread');</script>";
    echo "<script type='text/javascript'>location.href='/work-sp';</script>";
}
include_once('footer.php');
?>