| Current Path : /home/bolconlineco/public_html/coordinator/ |
| Current File : /home/bolconlineco/public_html/coordinator/excel.php |
<?php
include('../includes/connection/func.inc.php');
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=codelution-export.xls");
if(!empty($_POST['studentId']))
{
$studentId=sql_strip($_POST['studentId']);
$result=mysql_query("select * from student where rollno='$studentId'");
}else if(!empty($_POST['email'])) {
$email=sql_strip($_POST['email']);
$result=mysql_query("select * from student where email like '%$email%'");
}else if(!empty($_POST['firstname']))
{
$firstname=sql_strip($_POST['firstname']);
$result=mysql_query("select * from student where fname like '%$firstname%' order by registrationdate");
$num=mysql_num_rows($result);
}else if(!empty($_POST['lastname']))
{
$lastname=sql_strip($_POST['lastname']);
$result=mysql_query("select * from student where lname like '%$lastname%' order by registrationdate");
}else if(!empty($_POST['tutor']))
{
// Return more rows
$tutr=sql_strip($_POST['tutor']);
$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($_POST['country']))
{
$country=$_POST['country'];
$result=mysql_query("select * from student where country like '%$country%' order by registrationdate");
}else if(!empty($_POST['city']))
{
$city=sql_strip($_POST['city']);
$result=mysql_query("select * from student where city like '%$city%' order by registrationdate");
}else if(!empty($_POST['dob']))
{
$dob=$_POST['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($_POST['registfrom']) && !empty($_POST['rto'])){
$date2=$_POST['registfrom'];
$full2=explode('-',$date2);
$course= isset($_POST['course']) ? sql_strip($_POST['course']):'';
$category=sql_strip($_POST['category']);
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_POST['rto'];
$full=explode('-',$date1);
$sta=$_POST['sstatus'];
$rto=$full[2].'-'.$full[1].'-'.$full[0];
// echo $date2."<br>";
// echo $sta."<br>";
// echo $course."<br>";
// print_r($date1);
$sql_query = "select s.*,ac.* from student as s
join assigncourse as ac on s.rollno=ac.rollno
join course as c on c.courseId=ac.courseid
where s.registrationdate between '$date2' and '$date1'
";
$sql_query .= (!empty($_POST['category']))? " and c.catId='$category' ":'' ;
$sql_query .= (!empty($_POST['course']))? " and ac.courseid='$course' ":'' ;
$sql_query .= (!empty($_POST['sstatus']))? " and studentstatus='$sta' ":'' ;
$sql_query .= " order by s.registrationdate";
$result=mysql_query($sql_query);
// print_r(mysql_fetch_array($result));exit();
}
/*
elseif(!empty($_POST['registfrom']) && !empty($_POST['rto']) && !empty($_POST['category']) && !empty($_POST['course'])){
$date2=$_POST['registfrom'];
$full2=explode('-',$date2);
$course=sql_strip($_POST['course']);
$category=sql_strip($_POST['category']);
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_POST['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
join course as c on c.courseId=ac.courseid
where s.registrationdate between '$date2' and '$date1'
and c.catId='$category'
and ac.courseid='$course'
order by s.registrationdate");
// print_r(mysql_fetch_array($result));exit();
}elseif(!empty($_POST['registfrom']) && !empty($_POST['rto']) && !empty($_POST['category'])){
$date2=$_POST['registfrom'];
$full2=explode('-',$date2);
$category=sql_strip($_POST['category']);
$course=sql_strip($_POST['course']);
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_POST['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
join course as c on c.courseId=ac.courseid
where
s.registrationdate between '$date2' and '$date1' and c.catId='$category' order by s.registrationdate");
// print_r(mysql_fetch_array($result));exit();
}else if(!empty($_POST['registfrom']) && !empty($_POST['rto'])&& !empty($_POST['sstatus'])){
$date2=$_POST['registfrom'];
$full2=explode('-',$date2);
// print_r($full2);
// exit();
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_POST['rto'];
$full=explode('-',$date1);
$sta=$_POST['sstatus'];
$rto=$full[2].'-'.$full[1].'-'.$full[0];
//$from=date('Y-m-d',strtotime($_POST['registfrom']));
//$too=date('Y-m-d',strtotime($_POST['rto']));
$result=mysql_query("select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
s.registrationdate between '$date2' and '$date1' and studentstatus='$sta' order by s.registrationdate");
} else if (!empty($_POST['registfrom']) && !empty($_POST['rto'])) {
$date2=$_POST['registfrom'];
$full2=explode('-',$date2);
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_POST['rto'];
$full=explode('-',$date1);
$rto=$full[2].'-'.$full[1].'-'.$full[0];
//$from=date('Y-m-d',strtotime($_POST['registfrom']));
//$too=date('Y-m-d',strtotime($_POST['rto']));
// echo "select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
// s.registrationdate between '$date2' and '$date1' order by s.registrationdate";exit;
$result=mysql_query("select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
s.registrationdate between '$date2' and '$date1' order by s.registrationdate");
// print_r(mysql_fetch_array($result));exit();
}
*/
else if(!empty($_POST['compfrom']) && !empty($_POST['compto'])){
$date2=$_POST['compfrom'];
$full2=explode('/',$date2);
$rfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_POST['compto'];
$full=explode('/',$date1);
$rto=$full[2].'-'.$full[1].'-'.$full[0];
//$from=date('Y-m-d',strtotime($_POST['registfrom']));
//$too=date('Y-m-d',strtotime($_POST['rto']));
$result=mysql_query("select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno where
s.comp_date between '$rfrom' and '$rto' order by s.registrationdate");
}
else if(!empty($_POST['taskfrom']) && !empty($_POST['taskto'])) {
$date2=$_POST['taskfrom'];
$full2=explode('/',$date2);
$taskfrom=$full2[2].'-'.$full2[1].'-'.$full2[0];
$date1=$_POST['taskto'];
$full=explode('/',$date1);
$taskto=$full[2].'-'.$full[1].'-'.$full[0];
$result=mysql_query("select s.*,t.* from student as s join tasks as t on s.rollno=t.rollno where
t.taskdate between '$taskfrom' and '$taskto' group by s.rollno order by t.taskdate,s.registrationdate");
} else if(!empty($_POST['assg_task'])) {
$result=mysql_query("select s.*,t.* from student as s join tasks as t on s.rollno=t.rollno where t.assigned_to = '".$_POST['assg_task']."' group by s.rollno order by t.taskdate,s.registrationdate");
}
else if(!empty($_POST['balfrom']) && !empty($_POST['balto']))
{
$balfrom=date($_POST['balfrom']);
$balto=date($_POST['balto']);
//$result=mysql_query("select s.*,sum(tf.paid) as total from student as s inner join tbl_fees_install as tf on s.rollno=tf.rollno group by s.rollno having total between '$balfrom' and '$balto' ") or die(mysql_error());
// $result=mysql_query("select s.*,abs(sum(tf.payble)-sum(f.paid)) as total from student as s join tbl_fees_install as tf on s.rollno=tf.rollno join tbl_install as f on tf.rollno=f.rollno group by s.rollno having total between '$balfrom' and '$balto'") or die(mysql_error());
$result=mysql_query("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 rollno having total_dues between '$balfrom' and '$balto'");
}
else if(!empty($_POST['from']) && !empty($_POST['to']))
{
$formm=date($_POST['from']);
$full1=explode('/',$formm);
$too=date($_POST['to']);
$full2=explode('/',$too);
$f=$full1[2].'-'.$full1[1].'-'.$full1[0];
$t=$full2[2].'-'.$full2[1].'-'.$full2[0];
if(isset($_POST['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($_POST['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
{
$result=mysql_query("select s.*,ua.* from student as s join uploadassignment as ua on s.rollno=ua.rollno where ua.uploadStatus=1 and ua.uploaddate between '$f' and '$t' group by s.rollno order by ua.uploaddate desc") or die(mysql_error());
}
}
else if(!empty($_POST['category']) && !empty($_POST['course']) && !empty($_POST['sstatus']))
{
//$category=sql_strip($_POST['category']);
$course=sql_strip($_POST['course']);
$status=sql_strip($_POST['sstatus']);
$query="select s.*,ac.* from student as s join assigncourse as ac on s.rollno=ac.rollno
where ac.courseid='$course' AND s.studentstatus='$status' order by s.registrationdate";
$result=mysql_query($query) or die(mysql_error());
// print_r(mysql_fetch_array($result)); exit();
} else if(!empty($_POST['category']) && !empty($_POST['course']))
{
//$category=sql_strip($_POST['category']);
$course=sql_strip($_POST['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());
}
else if(!empty($_POST['sstatus'])) {
$status=sql_strip($_POST['sstatus']);
//$query="select * from student where studentstatus='$status'";
$result=mysql_query("select * from student where studentstatus='$status' order by registrationdate");
}
else if(!empty($_POST['source'])) {
$source=sql_strip($_POST['source']);
//$query="select * from student where studentstatus='$status'";
$result=mysql_query("select * from student where admission_source='$source' order by registrationdate");
}
else if(!empty($_POST['stage'])) {
$stage=sql_strip($_POST['stage']);
//$query="select * from student where studentstatus='$status'";
$result=mysql_query("select * from student where stage='$stage' order by registrationdate");
}
?>
<div style="clear: both;"></div>
<div class="table-responsive">
<table border="1">
<thead>
<tr>
<th>#</th>
<th>ID</th>
<th >Reg Date</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Country</th>
<th>Course</th>
<th>Source</th>
<th>Status</th>
<!-- <th>Cource</th> -->
<!-- <th>Stage</th>
<th>Level</th>
<th>Task</th> -->
<!-- <th>Assignment</th>
<th>I</th>
<th>C</th>
<th>A</th> -->
<!--<th>Paid</th>
<th>Bal</th>
<th>Due</th>-->
<!-- <th>Login</th> -->
</tr><!-- end title -->
</thead>
<tbody>
<?php
$stage_array = array();
$status_array = array();
$status_q = mysql_query("SELECT StatusId,StatusName FROM status");
while($status_res=mysql_fetch_array($status_q))
{
$status_array[$status_res['StatusId']] = $status_res['StatusName'];
}
// $stage_q = mysql_query("SELECT id,title FROM stages");
// while($stage_res=mysql_fetch_array($stage_q))
// {
// $stage_array[$stage_res['id']] = $stage_res['title'];
// }
$number=1;
$numresult=mysql_num_rows($result);
$sr=0;
if ($numresult > 0) {
while($row=mysql_fetch_array($result))
{
$email_found = $row['email'];
$course_name = ''; ?>
<tr>
<td><?php echo $number++;?></td>
<td><a href="studentInfo.php?Id=<?php echo $row['rollno']; ?>" target="_new" ><?php echo $row['rollno'];?></a></td>
<td><?php echo date('d/m/Y',strtotime($row['registrationdate']));?></td>
<td><?php echo $row['fname'];?></td>
<td><?php echo $row['lname']; ?></td>
<td><?php echo $row['email'];?></td>
<td><?php echo $row['country'];?></td>
<?php
$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'];
}
?>
<td><?php echo $course_name; //echo $course_id;?></td>
<td><?php echo $row['admission_source'];?></td>
<td><?php
echo array_key_exists($row['studentstatus'], $status_array) ?$status_array[$row['studentstatus']]:'';
// echo $login_row['StatusName'];
?></td>
<?php /*<td>
<?php
$rollno = $row['rollno'];
$email = $row['email'];
?>
<a target="_blank" href="loginasanadmin.php?rollno=<?php echo $rollno; ?>&studentEmail=<?php echo $email; ?>" >Login</a>
<a href="register.php?rollno=<?php echo $rollno; ?>" class="">Register</a>
</td>*/ ?>
</tr>
<?php
}
}
?>
</tbody>
</table>