Domain: amberpublishers.in
Server Adress: 86.38.243.169
privdayz.com
<?php
require('data_base_connection_xyzabc.php');
$conection = $conn;
date_default_timezone_set('asia/kolkata');
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
// ---------------------- File upload start ------------------------
require 'phpspreadsheet/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
// ---------------------- File upload end ------------------------
$states = array(
'Andhra Pradesh',
'Arunachal Pradesh',
'Assam',
'Bihar',
'Chhattisgarh',
'Goa',
'Gujarat',
'Haryana',
'Himachal Pradesh',
'Jammu & Kashmir',
'Jharkhand',
'Karnataka',
'Kerala',
'Madhya Pradesh',
'Maharashtra',
'Manipur',
'Meghalaya',
'Mizoram',
'Nagaland',
'Odisha',
'Punjab',
'Rajasthan',
'Sikkim',
'Tamil Nadu',
'Tripura',
'Uttarakhand',
'Uttar Pradesh',
'West Bengal',
'Andaman & Nicobar',
'Chandigarh',
'Dadra and Nagar Haveli',
'Daman & Diu',
'Delhi',
'Lakshadweep',
'Puducherry'
);
function send_mail($receiver, $body, $sub)
{
$mail = new PHPMailer();
// $mail->SMTPDebug=3;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->Port = "465";
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Username = "[email protected]";
$mail->Password = "[email protected]";
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->SetFrom("[email protected]", "KMCLU SUGAM Dashboard");
$mail->Subject = $sub;
$mail->Body = $body;
$mail->AddAddress($receiver);
$mail->SMTPOptions = array('ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => false
));
if (!$mail->Send()) {
return false;
} else {
return true;
}
}
// ---------------------------- Message Function Start--------------------
function SuccessFun($Message)
{
echo "
<div class='alert alert-success alert-dismissible fade show' role='alert'>
<strong>$Message</strong>
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>
";
echo "<script>
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href)
}
</script>";
}
function DangerFun($Message)
{
echo "
<div class='alert alert-danger alert-dismissible fade show' role='alert'>
<strong>$Message</strong>
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>
";
echo "<script>
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href)
}
</script>";
}
// ---------------------------- Message Function end--------------------
// ------------------------------- Import Files start ------------------------
function ImportFiles($file_tmp)
{
$inputFileNamePath = $file_tmp;
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileNamePath);
$maxCell = $spreadsheet->getActiveSheet()->getHighestRowAndColumn();
$data = $spreadsheet->getActiveSheet()->rangeToArray('A1:' . $maxCell['column'] . $maxCell['row']);
return $data;
}
function remove_empty_cell(array $data)
{
for ($i = count($data) - 1; $i >= 0; $i--) {
$check = implode('', $data[$i]);
if (empty($check)) {
unset($data[$i]);
}
}
return array_values($data);
}
function import_data_with_images($file_name)
{
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name);
$worksheet = $spreadsheet->getActiveSheet();
$maxCell = $worksheet->getHighestRowAndColumn();
$data = $worksheet->rangeToArray('A1:' . $maxCell['column'] . $maxCell['row']);
$maxcol = count($data[0]);
$store_img_arr = array();
for ($i = 0; $i < count($worksheet->getDrawingCollection()); $i++) {
$drawing = $worksheet->getDrawingCollection()[$i];
$zipReader = fopen($drawing->getPath(), 'r');
$imageContents = '';
$extension = $drawing->getExtension();
while (!feof($zipReader)) {
$imageContents .= fread($zipReader, 1024);
}
$filename = substr(md5(mt_rand(1000, 100000)), 20) . '.' . $extension;
// file_put_contents($filename, $imageContents);
$data[$i + 1][$maxcol - 1] = $filename;
$store_img_arr[$filename] = $imageContents;
fclose($zipReader);
}
return array($data, $store_img_arr);
}
// ------------------------------- Import Files end ------------------------
// -------------------------------- Go back Start ----------------------
function goback($id)
{
if (!isset($id)) {
echo "<script>window.history.back()</script>";
}
}
// -------------------------------- Go back end----------------------
// ----------------------------------- Real_escape string start-------------
function realEscape($data)
{
global $conection;
$escape = strip_tags(mysqli_real_escape_string($conection, trim($_POST[$data])));
return $escape;
}
// ----------------------------------- Real_escape string end-------------
// -----------------Some Pre-Defined Files Formate Array----------------
$pdf_format = ['pdf', 'PDF'];
$docx_format = ['docx', 'DOCX'];
$excel = ['xls', 'csv', 'xlsx'];
$img_format = ['jpg', 'JPG', 'jpeg', 'JPEG', 'png', 'PNG', 'gif', 'GIF', 'tif', 'tiff'];
$img_pdf_format = ['pdf', 'PDF', 'jpg', 'JPG', 'jpeg', 'JPEG', 'png', 'PNG', 'gif', 'GIF', 'tif', 'tiff'];
function file_format($file, array $file_format)
{
$get_file_ext = pathinfo($file, PATHINFO_EXTENSION);
if (!in_array($get_file_ext, $file_format)) {
return false;
} else {
return true;
}
}
function new_fileName($file_name)
{
$new_file_ext = pathinfo($file_name, PATHINFO_EXTENSION);
$new_name = substr(md5($file_name) . mt_rand(1000, 10000), 22) . '.' . $new_file_ext;
return $new_name;
}
// ------------------------------------------ Delete Only Data Not File Function Start------------------
function delete_single($table, $col_id)
{
global $conection;
$delete = "DELETE FROM `$table` WHERE col_id = '$col_id'";
if (mysqli_query($conection, $delete)) {
$check = "SELECT * FROM `$table` WHERE col_id = '$col_id'";
$check_query = mysqli_query($conection, $check);
$check_row = mysqli_num_rows($check_query);
if ($check_row != 0) {
return false;
} else {
return true;
}
} else {
return false;
}
}
// function delete_single_from_many_table(array $delete_data)
// {
// global $conection;
// $success = 0;
// for ($i = 0; $i < count($delete_data); $i++) {
// $table = $delete_data[$i]['table'];
// $col_id = $delete_data[$i]['col_id'];
// $select = "SELECT * FROM `$table` where col_id = '$col_id'";
// $query = mysqli_query($conection, $select);
// $row = mysqli_num_rows($query);
// if ($row != 0) {
// mysqli_query($conection, "DELETE FROM `$table` WHERE col_id = '$col_id'");
// $success++;
// }
// }
// if ($success != 0) {
// return true;
// } else {
// return false;
// }
// }
function delete_multiple($table_name, array $col_ids)
{
global $conection;
$success = 0;
for ($i = 0; $i < count($col_ids); $i++) {
$Delete = "DELETE FROM `$table_name` WHERE col_id = '$col_ids[$i]'";
$Select = "SELECT * FROM `$table_name` WHERE col_id = '$col_ids[$i]'";
$query = mysqli_query($conection, $Select);
$Row = mysqli_num_rows($query);
if ($Row != 0) {
if (mysqli_query($conection, $Delete)) {
$select_again = "SELECT * FROM `$table_name` WHERE col_id = '$col_ids[$i]'";
$query_again = mysqli_query($conection, $select_again);
$Check_row = mysqli_num_rows($query_again);
if ($Check_row == 0) {
$success++;
}
}
}
}
if ($success == 0) {
DangerFun('Failed To Delete Data');
} else {
SuccessFun('Total ' . $success . ' Data Deleted Successfully');
}
}
function delete_single_with_file($table_name, $col_ids, array $file_arr, $path)
{
// add '/' in the path at last
global $conection;
$Delete = "DELETE FROM `$table_name` WHERE col_id = '$col_ids'";
$Select = "SELECT * FROM `$table_name` WHERE col_id = '$col_ids'";
$query = mysqli_query($conection, $Select);
$Row = mysqli_num_rows($query);
$fetch_data = mysqli_fetch_assoc($query);
if ($Row != 0) {
if (mysqli_query($conection, $Delete)) {
$select_again = "SELECT * FROM `$table_name` WHERE col_id = '$col_ids'";
$query_again = mysqli_query($conection, $select_again);
$Check_row = mysqli_num_rows($query_again);
if ($Check_row == 0) {
for ($j = 0; $j < count($file_arr); $j++) {
if (file_exists($path . $fetch_data[$file_arr[$j]])) {
unlink($path . $fetch_data[$file_arr[$j]]);
}
}
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
function delete_multiple_with_file($table_name, array $col_ids, array $file_arr, $path)
{
// add '/' in the path at last
global $conection;
$success = 0;
for ($i = 0; $i < count($col_ids); $i++) {
$Delete = "DELETE FROM `$table_name` WHERE col_id = '$col_ids[$i]'";
$Select = "SELECT * FROM `$table_name` WHERE col_id = '$col_ids[$i]'";
$query = mysqli_query($conection, $Select);
$Row = mysqli_num_rows($query);
$fetch_data = mysqli_fetch_assoc($query);
if ($Row != 0) {
if (mysqli_query($conection, $Delete)) {
$select_again = "SELECT * FROM `$table_name` WHERE col_id = '$col_ids[$i]'";
$query_again = mysqli_query($conection, $select_again);
$Check_row = mysqli_num_rows($query_again);
if ($Check_row == 0) {
$success++;
for ($j = 0; $j < count($file_arr); $j++) {
if ($fetch_data[$file_arr[$j]] != '') {
if (file_exists($path . $fetch_data[$file_arr[$j]])) {
unlink($path . $fetch_data[$file_arr[$j]]);
}
}
}
}
}
}
}
if ($success == 0) {
DangerFun('Failed To Delete Data');
} else {
SuccessFun('Total ' . $success . ' Data Deleted Successfully');
}
}
// ------------------------------------------ Delete Only Data Not File Function End------------------
// ---------------------------- Uid generator start-------------------------
function uid_generator()
{
$gen_uid = strtoupper(substr(md5(mt_rand(10000, 1000000)), 22));
return $gen_uid;
}
function check_uid_availibility($uid, $table)
{
global $conection;
$check_uid = "SELECT * FROM `$table` where uid = '$uid'";
$check_uid_q = mysqli_query($conection, $check_uid);
$check_uid_r = mysqli_num_rows($check_uid_q);
if ($check_uid_r != 0) {
return false;
} else {
return true;
}
}
// ---------------------------- Uid generator end-------------------------
// ---------------------------------------------- Function For get Select Options start---------------------
$months = array(
'January',
'February',
'March',
'April',
'May',
'June',
'July ',
'August',
'September',
'October',
'November',
'December',
);
function get_month()
{
global $months;
$str = "";
for ($i = 0; $i < count($months); $i++) {
$str .= "
<option value='$months[$i]'>$months[$i]</option>
";
}
return $str;
}
function get_department()
{
global $conection;
$get_dep = mysqli_query($conection, "SELECT DISTINCT dep FROM `courses` order by dep asc");
$str = "";
while ($get_dep_f = mysqli_fetch_assoc($get_dep)) {
$str .= "
<option value='$get_dep_f[dep]'>$get_dep_f[dep]</option>
";
}
return $str;
}
function get_courses()
{
global $conection;
$get_course = mysqli_query($conection, "SELECT DISTINCT course FROM `courses` order by course asc");
$str = "";
while ($get_course_f = mysqli_fetch_assoc($get_course)) {
$str .= "
<option value='$get_course_f[course]'>$get_course_f[course]</option>
";
}
return $str;
}
function get_states()
{
global $states;
$str = "";
for ($i = 0; $i < count($states); $i++) {
$str .= "
<option value='$states[$i]'>$states[$i]</option>
";
}
return $str;
}
function get_academic_session()
{
global $conection;
$str = "";
$get_Aca_Session = mysqli_query($conection, "SELECT * FROM `academic_session` order by academic_session ASC");
while ($get_aca_session_f = mysqli_fetch_assoc($get_Aca_Session)) {
$str .= "
<option value='$get_aca_session_f[academic_session]'>$get_aca_session_f[academic_session]</option>
";
}
return $str;
}
function get_semeter()
{
$str = "";
$str .= "
<option value = '1'>1</option>
<option value = '2'>2</option>
<option value = '3'>3</option>
<option value = '4'>4</option>
<option value = '5'>5</option>
<option value = '6'>6</option>
<option value = '7'>7</option>
<option value = '8'>8</option>
";
return $str;
}
function get_year()
{
$str = "";
$str .= "
<option value = '1'>1</option>
<option value = '2'>2</option>
<option value = '3'>3</option>
<option value = '4'>4</option>
";
return $str;
}
function get_paper_code()
{
global $conection;
$str = "";
$get_paper_code = mysqli_query($conection, "SELECT DISTINCT paper_code FROM `papers` order by paper_code ASC");
while ($get_paper_code_f = mysqli_fetch_assoc($get_paper_code)) {
$str .= "
<option value='$get_paper_code_f[paper_code]'>$get_paper_code_f[paper_code]</option>
";
}
return $str;
}
// ---------------------------------------------- Function For get Select Options end---------------------
// --------------------------------------- Indian Number System start--------------------------------
function IND_num_format($number)
{
$decimal = (string)($number - floor($number));
$money = floor($number);
$length = strlen($money);
$delimiter = '';
$money = strrev($money);
for ($i = 0; $i < $length; $i++) {
if (($i == 3 || ($i > 3 && ($i - 1) % 2 == 0)) && $i != $length) {
$delimiter .= ',';
}
$delimiter .= $money[$i];
}
$result = strrev($delimiter);
$decimal = preg_replace("/0\./i", ".", $decimal);
$decimal = substr($decimal, 0, 3);
if ($decimal != '0') {
$result = $result . $decimal;
}
return $result;
}
// --------------------------------------- Indian Number System end--------------------------------
// ------------------------------ Academic Session Generator start----------------
function generate_academic_session()
{
$current_y = date('Y');
for ($i = 0; $i < 5; $i++) {
$aca_session = ($current_y + $i) . '-' . (substr($current_y, 2) + $i + 1);
echo "<option value ='$aca_session'>$aca_session</option>";
}
}
// ------------------------------ Academic Session Generator end----------------
function get_credit($course, $year, $sem, $paper_code)
{
global $conection;
$get_credit = mysqli_query($conection, "SELECT * FROM `papers` where course = '$course' and year = '$year' and sem = '$sem' and paper_code = '$paper_code'");
$credit = mysqli_fetch_assoc($get_credit);
return $credit['credit'];
}
function get_grade($marks)
{
if ($marks != '') {
if ($marks >= 90 && $marks <= 100) {
return array('O', 10);
} elseif ($marks >= 80 && $marks < 90) {
return array('A+', 9);
} elseif ($marks >= 70 && $marks < 80) {
return array('A', 8);
} elseif ($marks >= 60 && $marks < 70) {
return array('B+', 7);
} elseif ($marks >= 50 && $marks < 60) {
return array('B', 6);
} elseif ($marks >= 45 && $marks < 50) {
return array('C', 5);
} elseif ($marks >= 40 && $marks < 45) {
return array('P', 4);
} elseif ($marks >= 0 && $marks < 40) {
return array('F', 0);
}
} else {
return array('AB', 0);
}
}
// function get_result(array $internal, array $external)
// {
// // array(array('min' => 20, 'obt' => 50), array('min' => 10, 'obt' => 30));
// $result = 'PASSED';
// for ($i = 0; $i < count($internal); $i++) {
// $int_min = $internal[$i]['min'];
// $int_obt = $internal[$i]['obt'];
// $ext_min = $external[$i]['min'];
// $ext_obt = $external[$i]['obt'];
// if ($int_obt < $int_min) {
// $result = 'FAILED';
// break;
// } elseif ($ext_obt < $ext_min) {
// $result = 'PROMOTED';
// break;
// }
// }
// return $result;
// }
function get_int_ext_min($course, $year, $sem, $paper_code)
{
global $conection;
$get_int_ext = mysqli_query($conection, "SELECT * FROM `papers` where course = '$course' and year = '$year' and sem = '$sem' and paper_code = '$paper_code'");
if (mysqli_num_rows($get_int_ext) != 0) {
$get_int_ext_f = mysqli_fetch_assoc($get_int_ext);
return array($get_int_ext_f['int_min'], $get_int_ext_f['ext_pra_min']);
} else {
return false;
}
}
function get_result_and_back_paper($enroll_no)
{
global $conection;
$get_result = mysqli_query($conection, "SELECT * FROM `marksheet_data` where enroll_no = '$enroll_no'");
$get_result_r = mysqli_num_rows($get_result);
$back_papers = array();
$failed_papers = array();
if ($get_result_r != 0) {
while ($get_result_f = mysqli_fetch_assoc($get_result)) {
$get_paper_code = $get_result_f['paper_code'];
$check_paper_type = mysqli_query($conection, "SELECT * FROM `papers` where course = '$get_result_f[course]' and year = '$get_result_f[year]' and sem = '$get_result_f[sem]' and paper_code = '$get_paper_code'");
$check_row = mysqli_num_rows($check_paper_type);
if ($check_row != 0) {
$check_f = mysqli_fetch_assoc($check_paper_type);
$elective_sub = $check_f['elective_subject'];
if ($elective_sub != 'QUALIFYING' && $get_result_f['status'] == 'PROMOTTED') {
array_push($back_papers, $get_result_f['paper_code']);
} elseif ($elective_sub != 'QUALIFYING' && $get_result_f['status'] == 'FAILED') {
array_push($failed_papers, $get_result_f['paper_code']);
}
}
}
if (count($back_papers) == 0 && count($failed_papers) == 0) {
return 'PASSED';
} else {
return array($back_papers, $failed_papers);
}
}
}
function calculate_all_sem_sgpa($enroll_no)
{
global $conection;
$sgpa_arr = array();
$get_sem = mysqli_query($conection, "SELECT DISTINCT sem FROM `marksheet_data` where enroll_no = '$enroll_no'");
$get_sem_r = mysqli_num_rows($get_sem);
if ($get_sem_r != 0) {
while ($get_sem_f = mysqli_fetch_assoc($get_sem)) {
$get_sem_data = $get_sem_f['sem'];
$get_marks = mysqli_query($conection, "SELECT * FROM `marksheet_data` where enroll_no = '$enroll_no' and sem = '$get_sem_data'");
$get_marks_r = mysqli_num_rows($get_marks);
$credit_arr = array();
$credit_point_arr = array();
if ($get_marks_r != 0) {
while ($get_marks_f = mysqli_fetch_assoc($get_marks)) {
$int_obt = $get_marks_f['int_obt'];
$ext_pra_obt = $get_marks_f['ext_pra_obt'];
$get_credit = get_credit($get_marks_f['course'], $get_marks_f['year'], $get_marks_f['sem'], $get_marks_f['paper_code']);
$total_marks = $int_obt + $ext_pra_obt;
$get_grade = get_grade($total_marks);
$get_grade_point = $get_grade[1];
$credit_point = $get_credit * $get_grade_point;
array_push($credit_arr, $get_credit);
array_push($credit_point_arr, $credit_point);
}
$total_credit = array_sum($credit_arr);
$total_credit_point = array_sum($credit_point_arr);
$sgpa = round(($total_credit_point / $total_credit), 2);
array_push($sgpa_arr, $sgpa);
}
}
return $sgpa_arr;
} else {
return 0;
}
}
function calculate_cgpa($enroll_no)
{
global $conection;
$sgpa_credit_pro_arr = array();
$total_credit_arr = array();
$get_sem = mysqli_query($conection, "SELECT DISTINCT sem FROM `marksheet_data` where enroll_no = '$enroll_no'");
$get_sem_r = mysqli_num_rows($get_sem);
if ($get_sem_r != 0) {
while ($get_sem_f = mysqli_fetch_assoc($get_sem)) {
$get_sem_data = $get_sem_f['sem'];
$get_marks = mysqli_query($conection, "SELECT * FROM `marksheet_data` where enroll_no = '$enroll_no' and sem = '$get_sem_data'");
$get_marks_r = mysqli_num_rows($get_marks);
$credit_arr = array();
$credit_point_arr = array();
if ($get_marks_r != 0) {
while ($get_marks_f = mysqli_fetch_assoc($get_marks)) {
$int_obt = $get_marks_f['int_obt'];
$ext_pra_obt = $get_marks_f['ext_pra_obt'];
$get_credit = get_credit($get_marks_f['course'], $get_marks_f['year'], $get_marks_f['sem'], $get_marks_f['paper_code']);
$total_marks = $int_obt + $ext_pra_obt;
$get_grade = get_grade($total_marks);
$get_grade_point = $get_grade[1];
$credit_point = $get_credit * $get_grade_point;
array_push($credit_arr, $get_credit);
array_push($credit_point_arr, $credit_point);
}
$total_credit = array_sum($credit_arr);
$total_credit_point = array_sum($credit_point_arr);
$sgpa = round(($total_credit_point / $total_credit), 2);
$pro_sgpa_credit = $sgpa * $total_credit;
array_push($sgpa_credit_pro_arr, $pro_sgpa_credit);
array_push($total_credit_arr, $total_credit);
}
}
$sgpa_credit_pro_sum = array_sum($sgpa_credit_pro_arr);
$credit_sum = array_sum($total_credit_arr);
$cgpa = round(($sgpa_credit_pro_sum / $credit_sum), 2);
return $cgpa;
}
}
function lock_marksheet(array $lock_marksheet)
{
global $conection;
$d = array();
for ($i = 0; $i < count($lock_marksheet); $i++) {
$json_data = json_decode($lock_marksheet[$i], true);
$d[$json_data[0]] = array('year' => $json_data[1], 'sem' => $json_data[2]);
}
$enroll_no = array_keys($d);
$n = 0;
for ($i = 0; $i < count($enroll_no); $i++) {
$year = $d[$enroll_no[$i]]['year'];
$sem = $d[$enroll_no[$i]]['sem'];
$get_academic_info = mysqli_query($conection, "SELECT * FROM `marksheet_data` where enroll_no = '$enroll_no[$i]' and year = '$year' and sem = '$sem' ");
$check_r = mysqli_num_rows($get_academic_info);
if ($check_r != 0) {
$get_data = mysqli_fetch_assoc($get_academic_info);
$check_already_locked = mysqli_query($conection, "SELECT * FROM `locked_marksheet` WHERE enroll_no = '$get_data[enroll_no]' and roll_no = '$get_data[roll_no]' and year = '$get_data[year]' and sem = '$get_data[sem]' and session = '$get_data[session]'");
$check_al_locked_r = mysqli_num_rows($check_already_locked);
if ($check_al_locked_r == 0) {
$Insert = "INSERT INTO `locked_marksheet`( `enroll_no`, `roll_no`, `year`, `sem`,`month`, `session`)
VALUES ('$get_data[enroll_no]','$get_data[roll_no]','$get_data[year]','$get_data[sem]','$get_data[month]','$get_data[session]')";
if (mysqli_query($conection, $Insert)) {
$n++;
}
}
}
}
if ($n != 0) {
SuccessFun("$n marksheet locked successfully");
} else {
DangerFun('Failed to lock marksheet');
}
}
function unlock_marksheet(array $lock_marksheet)
{
global $conection;
$d = array();
for ($i = 0; $i < count($lock_marksheet); $i++) {
$json_data = json_decode($lock_marksheet[$i], true);
$d[$json_data[0]] = array('year' => $json_data[1], 'sem' => $json_data[2]);
}
$enroll_no = array_keys($d);
$n = 0;
for ($i = 0; $i < count($enroll_no); $i++) {
$year = $d[$enroll_no[$i]]['year'];
$sem = $d[$enroll_no[$i]]['sem'];
$check_locked = mysqli_query($conection, "SELECT * FROM `locked_marksheet` WHERE enroll_no = '$enroll_no[$i]' and year = '$year' and sem = '$sem'");
$check_locked_r = mysqli_num_rows($check_locked);
if ($check_locked_r != 0) {
$Delete = "DELETE FROM `locked_marksheet` WHERE enroll_no = '$enroll_no[$i]' and year = '$year' and sem = '$sem'";
if (mysqli_query($conection, $Delete)) {
$n++;
}
}
}
if ($n != 0) {
SuccessFun("$n marksheet unlocked successfully");
} else {
DangerFun('Failed to unlock marksheet');
}
}
function lock_single_marksheet($enroll_no, $year, $sem)
{
global $conection;
$get_academic_info = mysqli_query($conection, "SELECT * FROM `marksheet_data` where enroll_no = '$enroll_no' and year = '$year' and sem = '$sem' ");
$check_r = mysqli_num_rows($get_academic_info);
if ($check_r != 0) {
$get_data = mysqli_fetch_assoc($get_academic_info);
$check_already_locked = mysqli_query($conection, "SELECT * FROM `locked_marksheet` WHERE enroll_no = '$get_data[enroll_no]' and roll_no = '$get_data[roll_no]' and year = '$get_data[year]' and sem = '$get_data[sem]' and session = '$get_data[session]'");
$check_al_locked_r = mysqli_num_rows($check_already_locked);
if ($check_al_locked_r == 0) {
$Insert = "INSERT INTO `locked_marksheet`( `enroll_no`, `roll_no`, `year`, `sem`,`month`, `session`)
VALUES ('$get_data[enroll_no]','$get_data[roll_no]','$get_data[year]','$get_data[sem]','$get_data[month]','$get_data[session]')";
if (mysqli_query($conection, $Insert)) {
SuccessFun('Marksheet Locked Successfully');
} else {
DangerFun('Failed To Lock Marksheet');
}
} else {
DangerFun('Marksheet already locked');
}
} else {
DangerFun('Failed To Lock Marksheet');
}
}
function unlock_single_marksheet($enroll_no, $year, $sem)
{
global $conection;
$check_locked = mysqli_query($conection, "SELECT * FROM `locked_marksheet` WHERE enroll_no = '$enroll_no' and year = '$year' and sem = '$sem'");
$check_locked_r = mysqli_num_rows($check_locked);
if ($check_locked_r != 0) {
$Delete = "DELETE FROM `locked_marksheet` WHERE enroll_no = '$enroll_no' and year = '$year' and sem = '$sem'";
if (mysqli_query($conection, $Delete)) {
SuccessFun('Marksheet Unlocked Successfully');
} else {
DangerFun('Failed To Unlock Marksheet');
}
} else {
DangerFun('Marksheet already unlocked');
}
}
function get_locked_marksheet($session)
{
global $conection;
$get_locked = mysqli_query($conection, "SELECT * FROM `locked_marksheet` where session = '$session'");
$get_locked_r = mysqli_num_rows($get_locked);
return IND_num_format($get_locked_r);
}
function get_unlocked_marksheet($session)
{
global $conection;
$n = 0;
$get_unlocked = mysqli_query($conection, "SELECT DISTINCT enroll_no, year, sem FROM `marksheet_data` WHERE session = '$session'");
while ($get_unlock_f = mysqli_fetch_assoc($get_unlocked)) {
$check_locked = mysqli_query($conection, "SELECT * FROM `locked_marksheet` where enroll_no = '$get_unlock_f[enroll_no]' and year = '$get_unlock_f[year]' and sem = '$get_unlock_f[sem]' ");
$check_locked_r = mysqli_num_rows($check_locked);
if ($check_locked_r == 0) {
$n++;
}
}
return IND_num_format($n);
}
function get_passed_stu($session)
{
global $conection;
$pass = 0;
$fail = 0;
$back = 0;
$status_arr = array();
$get_enroll = mysqli_query($conection, "SELECT DISTINCT enroll_no FROM `marksheet_data` WHERE session = '$session'");
if (mysqli_num_rows($get_enroll) != 0) {
while ($get_enroll_f = mysqli_fetch_assoc($get_enroll)) {
$get_dis_year_sem = mysqli_query($conection, "SELECT DISTINCT course,year, sem from `marksheet_data` where enroll_no = '$get_enroll_f[enroll_no]'");
if (mysqli_num_rows($get_dis_year_sem) != 0) {
while ($get_dis_year_sem_f = mysqli_fetch_assoc($get_dis_year_sem)) {
$get_dis_stu_data = mysqli_query($conection, "SELECT * FROM `marksheet_data` where enroll_no = '$get_enroll_f[enroll_no]' and year = '$get_dis_year_sem_f[year]' and sem = '$get_dis_year_sem_f[sem]' ");
$select_paper_count = mysqli_query($conection, "SELECT * FROM `papers` where course = '$get_dis_year_sem_f[course]' and year = '$get_dis_year_sem_f[year]' and sem = '$get_dis_year_sem_f[sem]' and elective_subject != 'QUALIFYING'");
$get_paper_count = mysqli_num_rows($select_paper_count);
$P = 0;
$F = 0;
$PRO = 0;
while ($get_dis_stu_f = mysqli_fetch_assoc($get_dis_stu_data)) {
$check_paper = mysqli_query($conection, "SELECT * FROM `papers` where paper_code = '$get_dis_stu_f[paper_code]' and course = '$get_dis_stu_f[course]' and year = '$get_dis_stu_f[year]' and sem = '$get_dis_stu_f[sem]' and elective_subject != 'QUALIFYING'");
if (mysqli_num_rows($check_paper) != 0) {
if ($get_dis_stu_f['status'] == 'PASSED') {
$P++;
} elseif ($get_dis_stu_f['status'] == 'FAILED') {
$F++;
} elseif ($get_dis_stu_f['status'] == 'PROMOTTED') {
$PRO++;
}
}
}
if ($P == $get_paper_count) {
$pass++;
} elseif ($F != 0) {
$fail++;
} elseif ($PRO != 0 && $F == 0) {
$back++;
}
}
}
}
}
return array($pass, $fail, $back);
}
function get_pending_status($certi_name)
{
global $conection;
$get_data = mysqli_query($conection, "SELECT * FROM `certificatedata` where certi_name = '$certi_name' and status = 'Pending'");
$get_r = mysqli_num_rows($get_data);
return $get_r;
}
function get_verified_status($certi_name)
{
global $conection;
$get_data = mysqli_query($conection, "SELECT * FROM `certificatedata` where certi_name = '$certi_name' and status = 'Verified'");
$get_r = mysqli_num_rows($get_data);
return $get_r;
}
function get_reject_status($certi_name)
{
global $conection;
$get_data = mysqli_query($conection, "SELECT * FROM `certificatedata` where certi_name = '$certi_name' and (status != 'Pending' and status !='Verified')");
$get_r = mysqli_num_rows($get_data);
return $get_r;
}
function change_date_format($date)
{
$new_date = date_format(date_create($date), 'd-M-Y');
return $new_date;
}
function get_verified_marksheet_status($status)
{
global $conection;
$get_data = mysqli_query($conection, "SELECT * FROM `marksheet_veri_req` where status = '$status'");
$get_r = mysqli_num_rows($get_data);
return $get_r;
}
function get_migration_sr_no()
{
global $conection;
$get_data = mysqli_query($conection, "SELECT * FROM `uploaded_certificates` where certi_name = 'Migration' order by col_id desc limit 1");
$get_r = mysqli_num_rows($get_data);
if ($get_r == 0) {
$new_certi_sr_no = 'MC000001/COE/KMCLU/' . date('y');
} else {
$get_data_f = mysqli_fetch_assoc($get_data);
$certi_sr_no = $get_data_f['certi_sr_no'];
$certi_sr_no_increment = substr($certi_sr_no, 2, 6) + 1;
$length_of_sr_no = strlen($certi_sr_no_increment);
$get_length_diff = 6 - $length_of_sr_no;
if ($get_length_diff != 0) {
for ($i = 0; $i < $get_length_diff; $i++) {
$new_certi_sr_incre = '0' . $certi_sr_no_increment;
$certi_sr_no_increment = $new_certi_sr_incre;
}
$new_certi_sr_no = "MC" . $new_certi_sr_incre . "/COE/KMCLU/" . date('y');
} else {
$new_certi_sr_no = "MC" . $certi_sr_no_increment . "/COE/KMCLU/" . date('y');
}
}
return $new_certi_sr_no;
}
function get_character_sr_no()
{
global $conection;
$get_data = mysqli_query($conection, "SELECT * FROM `uploaded_certificates` where certi_name = 'Character Certificate' order by col_id desc limit 1");
$get_r = mysqli_num_rows($get_data);
if ($get_r == 0) {
$new_certi_sr_no = 'CC000001/COE/KMCLU/' . date('y');
} else {
$get_data_f = mysqli_fetch_assoc($get_data);
$certi_sr_no = $get_data_f['certi_sr_no'];
$certi_sr_no_increment = substr($certi_sr_no, 2, 6) + 1;
$length_of_sr_no = strlen($certi_sr_no_increment);
$get_length_diff = 6 - $length_of_sr_no;
if ($get_length_diff != 0) {
for ($i = 0; $i < $get_length_diff; $i++) {
$new_certi_sr_incre = '0' . $certi_sr_no_increment;
$certi_sr_no_increment = $new_certi_sr_incre;
}
$new_certi_sr_no = "CC" . $new_certi_sr_incre . "/COE/KMCLU/" . date('y');
} else {
$new_certi_sr_no = "CC" . $certi_sr_no_increment . "/COE/KMCLU/" . date('y');
}
}
return $new_certi_sr_no;
}
function show_json_string($json)
{
return $json_decode = implode(', ', json_decode($json));
}
function get_challege_eva_status()
{
global $conection;
$get_data1 = mysqli_query($conection, "SELECT * FROM `challenge_eva` where file = ''");
$get_data2 = mysqli_query($conection, "SELECT * FROM `challenge_eva` where file != ''");
$get_r1 = mysqli_num_rows($get_data1);
$get_r2 = mysqli_num_rows($get_data2);
return array($get_r1, $get_r2);
}
function get_scrutiny_status()
{
global $conection;
$get_data1 = mysqli_query($conection, "SELECT * FROM `scrutiny` where status = 'Pending'");
$get_data2 = mysqli_query($conection, "SELECT * FROM `scrutiny` where status = 'Done'");
$get_r1 = mysqli_num_rows($get_data1);
$get_r2 = mysqli_num_rows($get_data2);
return array($get_r1, $get_r2);
}
function paymentVerification($roll_no, $fee_type)
{
// Initialize cURL
$ch = curl_init();
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, 'https://www.kmcluerp.in/fees-portal/srcadmis/srcpaystatus.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
// Set the request method to POST
curl_setopt($ch, CURLOPT_POST, true);
// Set the data to be sent in the request body
$data = array(
'api_key' => 'HASH669SRC',
'roll_number' => $roll_no,
'fee_type' => $fee_type,
'registration_id' => $roll_no,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Execute the request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
$error = curl_error($ch);
// Handle the error
return false;
}
// Close cURL
curl_close($ch);
// Process the response
if ($response) {
// Parse the response JSON or use it as needed
$data = json_decode($response, true);
// Process the data
return $data;
} else {
// Handle the case when no response is received
return false;
}
}
