File: /var/www/nclive/wp-content/plugins/nc_plugin/api/nc_notification_data.php
<?php
include_once '../../../../wp-config.php';
global $wpdb;
$TT_EXAM = "sp_exam";
$TT_EXAM_LINKS = "sp_exam_links";
$TT_EXAM_CATEGORY = "sp_exam_category";
$TT_EXAM_ENTITY = "sp_exam_entity";
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$entity = $_POST['id'];
$filterType = $_POST['filter'];
$limit = (int)($_POST['limit'] ?? 10);
$exam_name = $_POST['exam_name'] ?? '';
$examname = trim($exam_name);
$start_limit = (int)($_POST['data_row'] ?? 0);
if ($start_limit != ''){
$start= (int)($_POST['data_row'] ?? 0);
$limitation = "limit $start, $limit";
} else{
$start = 0;
$limitation = "limit $start, $limit";
}
if ($filterType == 'lasthour'){
$current=date('Y-m-d',strtotime('-1 days'));
$filterDate = "and date(l.update_date)='$current'";
if($examname == ''){
$limitation = "limit $start, $limit";
}
} else if ($filterType == 'lastweek'){
$current=date('Y-m-d',strtotime('-7 days'));
$filterDate = "and date(l.update_date)>='$current'";
if($examname == ''){
$limitation = "limit $start, $limit";
}
} else if ($filterType == 'lastmonth'){
$current=date('Y-m-d',strtotime('-30 days'));
$filterDate = "and date(l.update_date)>='$current'";
if($examname == ''){
$limitation = "limit $start, $limit";
}
} else {
$filterDate = "";
}
if($examname != ''){
$limitation = "";
$subQry = "and e.exam_name LIKE '%$examname%'";
} else{
$subQry = "";
}
//total count for executing query
$examTotalCounts = $wpdb->get_results("select count(l.exam_id) FROM $TT_EXAM_LINKS as l LEFT JOIN $TT_EXAM as e on e.exam_id=l.exam_id WHERE l.status!='0' and e.status!='0' and l.entity_id='$entity' $filterDate $subQry group by l.exam_id, l.entity_id");
$examTotalCount = $wpdb->num_rows;
$examDetails = $wpdb->get_results("select l.id, l.exam_id, l.entity_id, l.display_text, n.name, l.date_type, e.url_slug, l.date, l.update_date, e.exam_name, e.total_vacancy, e.fee, c.img_icon FROM $TT_EXAM_LINKS as l LEFT JOIN $TT_EXAM as e on e.exam_id=l.exam_id LEFT JOIN $TT_EXAM_CATEGORY as c ON c.cat_id=e.cat_id LEFT JOIN $TT_EXAM_ENTITY as n ON n.id=l.entity_id WHERE l.status!='0' and e.status!='0' and n.status!='0' and l.entity_id='$entity' $filterDate $subQry order by l.update_date desc $limitation");
$examDetailCount = $wpdb->num_rows;
// $dataContent = '<div id="testdiv">';
foreach ($examDetails as $exam) {
$date = date('M j', strtotime($exam->update_date));
if ($exam->date_type == 'FT') {
$split_date = preg_split('/,+/', $exam->date);
$date1 = $split_date[0];
$startDate = date('j M Y', strtotime($date1));
$date2 = $split_date[1];
$endDate = date('j M Y', strtotime($date2));
$datetype = ' From ' . $startDate . ' To ' . $endDate;
} else if ($exam->date_type == 'T') {
$datetype = $exam->date;
}
else if ($exam->date_type == 'N') {
$datetype = date('jS M Y', strtotime($exam->date)) ;
}
if($exam->display_text != ''){
$display_text = $exam->display_text;
}else{
$display_text = $exam->name;
}
$dataContent =' <div class="col-md-6 col-sm-6 col-xs-12"> <div class="NotificationExamBox wow fadeInUp" > <div class="NotificationExamFlexBox">';
if($exam->img_icon != ''){
$dataContent .='<img height="33" width="33" alt="'.$exam->exam_name.'" src="../images/'.$exam->img_icon.'">';
}
$dataContent .='<div class="NotificationExamBoxDetails">';
$dataContent .='<a href="/exams/'.$exam->url_slug.'/" aria-label="Exam Name">'.$exam->exam_name.'</a>';
$dataContent .='<p style="display: block;"> <span style="margin-bottom: 6px;color:#135fb1;" title="'.$exam->name.'"><i class="fas fa-id-card"></i> '.$display_text.'</span>';
if ($datetype != '') {
$dataContent .='<span title="'.$exam->name.'" style="color: #ed2551;"><i class="fas fa-calendar-alt"></i>'.$datetype.'</span>';
}
$dataContent .='</p></div> </div>';
$dataContent .='<i class="far fa-bookmark"></i>
<i class="fas fa-bookmark" style="display: none;color: #f1c512;"></i> </div> </div>';
echo $dataContent ;
}
echo '<input type="hidden" name="page_count" value="'. $examDetailCount.'">';
echo '<input type="hidden" name="data_row_count" value="'.$examTotalCount.'">';
?>