File: /var/www/content-sp/work-sp/nqb_questions_add_report1.php
<?php
include_once('nqb_report_section1.php');
// error_reporting(0);
// error_reporting(E_ALL);
// ini_set('display_errors', 'On');
//check edit permissions
$fileName = str_replace('.php', '', basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']));
if (in_array($fileName, $pageArray)) {
$adminId = $editor_id;
$curDate = date('Y-m-d');
$SP_MEDIUM = 'csp_sp_medium';
$SP_EDITORS = 'csp_editors';
$SP_QUESTION = 'csp_sp_question';
$SP_QUES_HISTORY = 'csp_sp_question_history';
$SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';
$SP_MEDIUM = 'csp_sp_medium';
$SP_MASTER_CATEGORY = 'csp_sp_master_category';
$SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
//editors
$editors = $conn->query("SELECT editor_id,contact_name FROM $SP_EDITORS where team_id='3' and editor_status='1' order by contact_name");
/***remove filter */
if (isset($_REQUEST['remove_filter'])) {
unset($_SESSION['addp_subQuery']);
}
/**search */
$q_date = '';
$fromDate = '';
$toDate = '';
$qtype = '';
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'];
$subQuery = '';
if ($es_editor != '') {
$subQuery .= "and sq.add_by='$es_editor' ";
}
if ($es_ondate != '') {
$q_date = date('Y-m-d', strtotime($es_ondate));
$subQuery .= "and date(sq.add_date)='$q_date'";
}
if ($es_fromdate != '' && $es_todate != '') {
$fromDate = date('Y-m-d', strtotime($es_fromdate));
$toDate = date('Y-m-d', strtotime($es_todate));
$subQuery .= "and (date(sq.add_date) BETWEEN '$fromDate' AND '$toDate')";
}
$_SESSION['addp_subQuery'] = $subQuery;
}
if (!empty($_SESSION['addp_subQuery'])) {
$mergeFilter = $_SESSION['addp_subQuery'];
} else {
$mergeFilter = "and date(sq.add_date)='$curDate'";
}
// $getAddData = "SELECT sq.question_id,sq.add_date,m.medium_name,ed.contact_name FROM $SP_QUESTION as sq LEFT JOIN $SP_MEDIUM as m on m.medium_id=sq.medium_id LEFT JOIN $SP_EDITORS as ed on ed.editor_id=sq.add_by WHERE sq.question_id !='' $mergeFilter";
// $getWorkData = $conn->query($getAddData);
$questionAddP = "SELECT sq.master_id, sq.subject_id, sq.medium_id, sq.add_date as datee, count(sq.question_id) as totalad, m.master_name, m.source, ms.category_name, l.medium_name,ed.contact_name,sq.add_by FROM $SP_QUESTION as sq LEFT JOIN $SP_MASTER_CATEGORY as m ON m.master_id=sq.master_id LEFT JOIN $SP_MASTER_STRUCTURE as ms ON ms.sub_id=sq.subject_id LEFT JOIN $SP_MEDIUM as l on l.medium_id=sq.medium_id LEFT JOIN $SP_EDITORS as ed on editor_id=sq.add_by where sq.question_id!='' $mergeFilter group by sq.master_id, sq.subject_id, sq.medium_id, sq.add_by order by m.master_name, ms.category_name";
$mDataPf = $conn->query($questionAddP);
?>
<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;
}
</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();
});
</script>
<div class="row">
<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">Select Editor</label>
<div class="col-sm-10">
<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">
<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">
<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">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Questions Add Data</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>#</th>
<th>Master</th>
<th>Subject</th>
<th>Medium</th>
<th>Editor</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$totalq = 0;
while ($pf = $mDataPf->fetch_assoc()) {
$totalq = $totalq + $pf['totalad'];
$source = $pf['source'] != '' ? strtolower($pf['source']) : 'sp';
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $pf['master_name']; ?></td>
<td><?php echo $pf['category_name']; ?></td>
<td><?php echo $pf['medium_name']; ?></td>
<td><?php echo $pf['contact_name']; ?></td>
<td><a target='_blank' href="nqb_questions_add_combine_report_user_view.php?subject_id=<?php echo $pf['subject_id']; ?>&date=<?php echo $q_date; ?>&fromdate=<?php echo $fromDate; ?>&todate=<?php echo $toDate; ?>&medium_id=<?php echo $pf['medium_id']; ?>&t_type=primary&mType=<?php echo $source; ?>&qtype=<?php echo $qtype; ?>&editor=<?php echo $pf['add_by']; ?>"><?php echo $pf['totalad']; ?></a></td>
</tr>
<?php $i++;
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="page-footer">
<p class="no-s">Graposs Connect ©</p>
</div>
</div>
<!-- previous html backup -->
<!-- <table id="assign_table" class="display table" style="width: 100%; cellspacing: 0;">
<thead>
<tr>
<th>Id</th>
<th>Ques Id</th>
<th>Medium</th>
<th>Add By</th>
<th>Add Date</th>
</tr>
</thead>
<tbody>
<?php
//$i = 1;
//while ($gwd = $getWorkData->fetch_assoc()) {
?>
<tr>
<td><?php //echo $i;
?></td>
<td>
<a href="nqb_single_question_view?qId=<?php //echo $gwd['question_id'];
?>&secMed=2" target="_blank" rel="noopener noreferrer">
<?php //echo $gwd['question_id'];
?>
</a>
</td>
<td><?php //echo $gwd['medium_name'];
?></td>
<td><?php //echo $gwd['contact_name'];
?></td>
<td><?php //echo $gwd['add_date'];
?></td>
</tr>
<?php //$i++; }
?>
</tbody>
</table> -->
<?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');
?>