| Current Path : /home/bolconlineco/public_html/coordinator/ |
| Current File : //home/bolconlineco/public_html/coordinator/search_reg_excel_export.php |
<?php
ob_start();
session_start();
if(!isset($_SESSION['coordinator']) && $_SESSION['coordinatorrole'] != 2) {
header("location:../index.php");
exit();
}
include('../includes/connection/func.inc.php');
header('Cache-Control: max-age=900');
$outPut='';
$studentId = '';
$email = '';
$firstname = '';
$lastname = '';
$tutr= '';
$country= '';
$city= '';
$dob= '';
$d1= '';
$new= '';
$date2= '';
$rfrom= '';
$date1= '';
$full= '';
$sta= '';
$rto= '';
$rfrom= '';
$full2= '';
$taskfrom= '';
$taskto= '';
$assg_task= '';
$balfrom= '';
$balto= '';
$formm= '';
$too= '';
$f= '';
$t= '';
$course= '';
$status= '';
$stage= '';
$catagory='';
$assg_all='';
$assg_comp='';
if(isset($_SESSION['student_search']['Search']))
{
if(!empty($_SESSION['student_search']['studentId']))
{
$studentId=sql_strip($_SESSION['student_search']['studentId']);
//Main Query Start Here..
$result=mysql_query("select * from student where rollno='$studentId'");
}else if(!empty($_SESSION['student_search']['email'])) {
$email=sql_strip($_SESSION['student_search']['email']);
$result=mysql_query("select * from student where email like '%$email%'");
}else if(!empty($_SESSION['student_search']['firstname']))
{
$firstname=sql_strip($_SESSION['student_search']['firstname']);
$result=mysql_query("select * from student where fname like '%$firstname%' order by registrationdate");
}else if(!empty($_SESSION['student_search']['lastname']))
{
$lastname=sql_strip($_SESSION['student_search']['lastname']);
$result=mysql_query("select * from student where lname like '%$lastname%' order by registrationdate");
}else if(!empty($_SESSION['student_search']['tutor']))
{
$tutr=sql_strip($_SESSION['student_search']['tutor']);
$sql="select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
ac.tutorId='$tutr' order by registrationdate";// exit;
$result=mysql_query("select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
ac.tutorId='$tutr' order by registrationdate");
}else if(!empty($_SESSION['student_search']['country']))
{
$country=$_SESSION['student_search']['country'];
$result=mysql_query("select * from student where country like '%$country%' order by registrationdate");
}else if(!empty($_SESSION['student_search']['city']))
{
$city=sql_strip($_SESSION['student_search']['city']);
$result=mysql_query("select * from student where city like '%$city%' order by registrationdate");
}else if(!empty($_SESSION['student_search']['dob']))
{
$dob=$_SESSION['student_search']['dob'];
$d1=explode('/',$dob);
$new=$d1[2].'-'.$d1[1].'-'.$d1[0];
$result=mysql_query("select * from student where dob='$new' order by registrationdate");
}else if(!empty($_SESSION['student_search']['registfrom']) && !empty($_SESSION['student_search']['rto'])&& !empty($_SESSION['student_search']['sstatus'])){
$date2=$_SESSION['student_search']['registfrom'];
$full2=explode('/',$date2);
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_SESSION['student_search']['rto'];
$full=explode('/',$date1);
$sta=$_SESSION['student_search']['sstatus'];
$rto=$full[2].'-'.$full[1].'-'.$full[0];
$result=mysql_query("select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
s.registrationdate between '$rfrom' and '$rto' and studentstatus='$sta' order by s.registrationdate");
} else if (!empty($_SESSION['student_search']['registfrom']) && !empty($_SESSION['student_search']['rto']))
{
$date2=$_SESSION['student_search']['registfrom'];
$full2=explode('/',$date2);
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_SESSION['student_search']['rto'];
$full=explode('/',$date1);
$rto=$full[2].'-'.$full[1].'-'.$full[0];
$result=mysql_query("select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
s.registrationdate between '$rfrom' and '$rto' order by s.registrationdate");
}
else if(!empty($_SESSION['student_search']['compfrom']) && !empty($_SESSION['student_search']['compto'])){
$date2=$_SESSION['student_search']['compfrom'];
$full2=explode('/',$date2);
$compfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_SESSION['student_search']['compto'];
$full=explode('/',$date1);
$compto=$full[2].'-'.$full[1].'-'.$full[0];
$result=mysql_query("select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
s.comp_date between '$compfrom' and '$compto' order by s.registrationdate");
}
else if(!empty($_SESSION['student_search']['taskfrom']) && !empty($_SESSION['student_search']['taskto'])) {
$date2=$_SESSION['student_search']['taskfrom'];
$full2=explode('/',$date2);
$taskfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_SESSION['student_search']['taskto'];
$full=explode('/',$date1);
$taskto=$full[2].'-'.$full[1].'-'.$full[0];
$task_students_rollnos=[];
$task_students_rollnos_string = '';
$sql = "select distinct rollno from tasks where taskdate between '$taskfrom' and '$taskto'";
$result = mysql_query($sql, $con);
if (mysql_num_rows($result)) {
while ($tRow = mysql_fetch_array($result)) {
$task_students_rollnos[] = $tRow['rollno'];
$task_students_rollnos_string .= $tRow['rollno'] . ',' ;
}
}
$task_students_rollnos_string;
$numrows = count($task_students_rollnos);
if ($numrows) {
$task_students_rollnos_string= rtrim($task_students_rollnos_string,',');
}
$result=mysql_query("select s.* from student as s where
s.rollno in ($task_students_rollnos_string)") or die();
} else if(!empty($_SESSION['student_search']['assg_task'])) {
$assg_task = $_SESSION['student_search']['assg_task'];
$task_students_rollnos=[];
$task_students_rollnos_string = '';
$sql = "select distinct rollno from tasks where assigned_to = '".$_SESSION['student_search']['assg_task']."'";
$result = mysql_query($sql, $con);
if (mysql_num_rows($result)) {
while ($tRow = mysql_fetch_array($result)) {
$task_students_rollnos[] = $tRow['rollno'];
$task_students_rollnos_string .= $tRow['rollno'] . ',' ;
}
}
$task_students_rollnos_string;
$numrows = count($task_students_rollnos);
if ($numrows) {
$task_students_rollnos_string= rtrim($task_students_rollnos_string,',');
}
$result=mysql_query("select s.* from student as s where
s.rollno in ($task_students_rollnos_string)") or die();
}
else if(!empty($_SESSION['student_search']['balfrom']) && !empty($_SESSION['student_search']['balto']))
{
$balfrom=date($_SESSION['student_search']['balfrom']);
$balto=date($_SESSION['student_search']['balto']);
$sql_q = "select s.*,abs(sum(f.payble)-sum(f.paid)) as total_dues from student as s
join tbl_fees_install as f on s.rollno=f.rollno
group by s.rollno having total_dues between '$balfrom' and '$balto'";
$result=mysql_query($sql_q);
}
else if(!empty($_SESSION['student_search']['from']) && !empty($_SESSION['student_search']['to']))
{
$formm=date($_SESSION['student_search']['from']);
$full1=explode('/',$formm);
$too=date($_SESSION['student_search']['to']);
$full2=explode('/',$too);
$f=$full1[2].'-'.$full1[1].'-'.$full1[0];
$t=$full2[2].'-'.$full2[1].'-'.$full2[0];
if(isset($_SESSION['student_search']['assg_all']))
{
$result=mysql_query("select s.*,ua.* from student as s join uploadassignment as ua on s.rollno=ua.rollno where ua.uploaddate between '$f' and '$t' group by s.rollno order by ua.uploaddate desc") or die(mysql_error());
}
else if(isset($_SESSION['student_search']['assg_comp']))
{
$result=mysql_query("select s.*,ua.* from student as s join uploadassignment as ua on s.rollno=ua.rollno where ua.uploadStatus=0 and ua.uploaddate between '$f' and '$t' group by s.rollno order by ua.uploaddate desc") or die(mysql_error());
}
else
{
$upload_students_rollnos=[];
$upload_students_rollnos_string = '';
$sql = "select distinct rollno from uploadassignment where uploaddate between '$f' and '$t'";
$result = mysql_query($sql, $con);
if (mysql_num_rows($result)) {
while ($tRow = mysql_fetch_array($result)) {
$upload_students_rollnos[] = $tRow['rollno'];
$upload_students_rollnos_string .= $tRow['rollno'] . ',' ;
}
}
$upload_students_rollnos_string;
$numrows = count($upload_students_rollnos);
if ($numrows) {
$upload_students_rollnos_string= rtrim($upload_students_rollnos_string,',');
}
$result=mysql_query("select s.* from student as s where
s.rollno in ($upload_students_rollnos_string)") or die();
}
}else if(!empty($_SESSION['student_search']['category']) && !empty($_SESSION['student_search']['course']))
{
$course=sql_strip($_SESSION['student_search']['course']);
$query="select s.*,ac.* from student as s join assigncourse as ac on s.rollno = ac.rollno where ac.courseid = '$course' order by s.registrationdate";
$result=mysql_query($query) or die(mysql_error());
$num=mysql_num_rows($result);
} else if(!empty($_SESSION['student_search']['sstatus'])) {
$status=sql_strip($_SESSION['student_search']['sstatus']);
$result=mysql_query("select * from student where studentstatus='$status' order by registrationdate");
} else if(!empty($_SESSION['student_search']['stage'])) {
$stage=sql_strip($_SESSION['student_search']['stage']);
$result=mysql_query("select * from student where stage='$stage' order by registrationdate");
}
$outPut .=
'<table style="max-width: 100%;background-color: transparent;border-collapse: collapse;
border-spacing: 0;border: 1px solid #ddd;" id="sample_2">
<thead>
<tr>
<th style="border: 1px solid #ddd;">#</th>
<th style="border: 1px solid #ddd;">First Name</th>
<th style="border: 1px solid #ddd;">Last Name</th>
<th style="border: 1px solid #ddd;">Course</th>
<th style="border: 1px solid #ddd;">Source</th>
<th style="border: 1px solid #ddd;">Email</th>
<th style="border: 1px solid #ddd;">Country</th>
<th style="border: 1px solid #ddd;">Reg Date</th>
</tr><!-- end title -->
</thead>
<tbody>';
$number=1;
$numresult=mysql_num_rows($result);
$sr=0;
if ($numresult > 0) {
while($row=mysql_fetch_array($result)){
$course_name = '';
$course_query =" SELECT ac.courseid courseid,courseName FROM `assigncourse` as ac
join course c on c.courseId = ac.courseid
where ac.rollno= ".$row['rollno'] . ' limit 1';
$qqq=mysql_query($course_query) or die(mysql_errno());
if (mysql_num_rows($qqq))
{
$fetch=mysql_fetch_array($qqq);
$course_name =$fetch['courseName'];
$course_id =$fetch['courseid'];
}
$reg_date = date('d/m/Y',strtotime($row['registrationdate']));
$outPut .=
'<tr>
<td style="border: 1px solid #ddd;">'.$number++.'</td>
<td style="border: 1px solid #ddd;">'.$row['fname'].'</td>
<td style="border: 1px solid #ddd;">'.$row['lname'].'</td>
<td style="border: 1px solid #ddd;">'.$course_name.'</td>
<td style="border: 1px solid #ddd;">'.$row['admission_source'].'</td>
<td style="border: 1px solid #ddd;">'.$row['email'].'</td>
<td style="border: 1px solid #ddd;">'.$row['country'].'</td>
<td style="border: 1px solid #ddd;">'.$reg_date.'</td>
</tr>';
}//end while
}//end if
else {
$outPut .=
'<tr>
<td colspan="16">No Record(s) found against your search.</td>
</tr>';;
}
$outPut .=
'</tbody>
</table>';
header('Content-Type: application/vnd.ms-excel');
header('Content-disposition: attachment; filename=report'.rand().'.xls');
echo $outPut;
}// end if student_search
?>