<?php
include 'loader.php';
global $WebUser;
$user = $WebUser->getUser();
//$uid = $user['user']['id'];
$type= 'approved'; $addQ = 'AND ST.approved=1';
if(!empty($_GET['type'])){
$type = 'registerd';
$addQ = 'AND ST.approved=0';
}
if(!empty($_GET['action']) && $_GET['action']=='delete' && !empty($_GET['action-key'])){
$kdb->update("students", array('status'=>0), array('id'=> $_GET['action-key']) );
header('location:admissions.php'. ($type== 'registered' ? '?type=registered':'') );
setDisplayMessage("Student Deleted Successfully");
die;
}
if(!empty($_GET['action']) && $_GET['action']=='approve' && !empty($_GET['action-key'])){
$kdb->update("students", array('approved'=>1), array('id'=> $_GET['action-key']) );
header('location:admissions.php'. ($type== 'registered' ? '?type=registered':'') );
setDisplayMessage("Student Approved Successfully");
die;
}
$ctid = 0;
if(isset($_POST['franchise_id']))
{
$ctid = mysql_escape_string($_POST['franchise_id']);
$addQ = " AND ST.approved=1 AND ST.franchise_id = '$ctid'";
}
//$cats = $kdb->get_list("SELECT id, `company_name` FROM franchisee WHERE STATUS =1");
$query = "SELECT * FROM franchisee WHERE STATUS =1";
$cats = $kdb->get_list($query, array('id', 'company_name'));
if(isset($_POST['search']))
{
$search = $_POST['search_by'];
$addQ = " AND (ST.reg_no LIKE '%$search%' or ST.candidate_name like '%$search%') ";
}
if(isset($_POST['export-csv'])) {
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=admissions.csv');
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
// output the column headings
fputcsv($output, array('id', 'user_id', 'candidate_name', 'father_name', 'reg_no', 'uniqe_no', 'gender', 'dob', 'email', 'phone', 'mobile', 'address', 'city', 'state', 'zip_code', 'country', 'comments', 'rollno', 'category', 'father_occupation', 'annual_income', 'yearin', 'yearout', 'date_of_joining', 'approved', 'image', 'course_id', 'franchise_id', 'doc', 'status', 'r_status'));
// fetch the data
$rows = mysql_query('SELECT id, user_id, candidate_name, father_name, reg_no, uniqe_no, gender, dob, email, phone, mobile, address, city, state, zip_code, country, comments, rollno, category, father_occupation, annual_income, yearin, yearout, date_of_joining, approved, image, course_id, franchise_id, doc, status, r_status FROM students WHERE status=1');
// loop over the rows, outputting them
while ($row = mysql_fetch_assoc($rows))
fputcsv($output, $row);
die();
}
if(isset($_POST['export-pdf'])) {
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/pdf; charset=utf-8');
header('Content-Disposition: attachment; filename=admissions.pdf');
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
// output the column headings
$pdf = new PDF($output, array('id', 'user_id', 'candidate_name', 'father_name', 'reg_no', 'uniqe_no', 'gender', 'dob', 'email', 'phone', 'mobile', 'address', 'city', 'state', 'zip_code', 'country', 'comments', 'rollno', 'category', 'father_occupation', 'annual_income', 'yearin', 'yearout', 'date_of_joining', 'approved', 'image', 'course_id', 'franchise_id', 'doc', 'status', 'r_status'));
// fetch the data
$rows = mysql_query('SELECT id, user_id, candidate_name, father_name, reg_no, uniqe_no, gender, dob, email, phone, mobile, address, city, state, zip_code, country, comments, rollno, category, father_occupation, annual_income, yearin, yearout, date_of_joining, approved, image, course_id, franchise_id, doc, status, r_status FROM students WHERE status=1');
// loop over the rows, outputting them
while ($row = mysql_fetch_assoc($rows))
$pdf = new PDF($output, $row);
die();
}
include('../includes/header_admin.php');
$studs = paginate('students', "SELECT ST.id, ST.reg_no, ST.franchise_id, ST.uniqe_no, ST.candidate_name, ST.father_name, ST.email, ST.phone, ST.dob as date_of_birth, ST.image, CR.name as course, CT.name as category, CT.shortcode FROM students ST JOIN courses CR ON CR.id = ST.course_id JOIN categories CT ON CT.id = CR.category_id WHERE ST.status=1 $addQ",
'', array('order'=> 'ST.id DESC')
);
//echo count($studs); die();
$operations = array(
'approve'=> 'Approve',
'view' => array('format'=> WEB_ROOT.'admin/student_info.php?id={value}', 'text'=> 'View'),
'edit' => array('format'=> WEB_ROOT.'admin/admission.php?id={value}', 'text'=> 'Modify'),
'reset-password' => array('format'=> WEB_ROOT.'admin/reset_pwd.php?id={value}', 'text'=> 'Reset Pasword')
);
if($type=='approved'){
unset($operations['approve']);
}
$options = array(
'name'=> 'students', 'rows'=> $studs, 'paginator'=> true, 'sorting'=>false ,
'actionField'=> true,
'actionFieldOperations'=> $operations
);
$kt = new kTable($options);// 'c1' => array('handler'=> 'createInfo', 'text'=> 'Student Photo'),
$kt->columns = array(
array( 'custom'=>array('type'=> 'handler', 'handler'=> 'imageInfo'), 'displayText'=> 'Student Photo'),
array('custom'=>array('type'=> 'handler', 'handler'=> 'personalInfo'), 'displayText'=> 'Personal Information'),
array('custom'=>array('type'=> 'handler', 'handler'=> 'courseInfo'), 'displayText'=> 'Course Information')
);
function imageInfo($ev ){
global $kFiles;
// print_r($ev['rowIndex']);
$row = $ev['row'];
$img = $row['image'];
$uname = $row['candidate_name'];
return '<a href="student_info.php?id='.$row['id'].'" class="userlogo-icon"><img src="'. $kFiles->getImage('files/students_images/', $img) .'" alt="'.$uname.'" /></a>';
}
function personalInfo($ev ){
//print_r($ev['rowIndex']);
$row = $ev['row'];
$email = $row['email'];
$phone = $row['phone'];
$dob = $row['date_of_birth'];
$reg_no = $row['reg_no'];
$uni_code = $row['uniqe_no'];
$uname = $row['candidate_name'];
return "<p class=\"info-block\"><label>Name</label><span>$uname</span>".
(empty($email) ? '' : "<label>Email</label><span>$email</span>").
"<label>Reg. No.</label><span>$reg_no</span>".
(empty($uni_code) ? '' : "<label>Uniqe. No.</label><span>$uni_code</span>")."</p>";
}
function courseInfo($ev ){
//print_r($ev['row']);
$row = $ev['row'];
$course = $row['course'];
$categ = $row['category'];
return "<p class=\"info-block\"><label>Course Type</label><span>$categ</span> <label>Course Name</label><span>$course</span></p>";
}
?>
<div id="content_wrapper">
<!--left nav -->
<?php include("../includes/admin_links.php");?>
<!--left nav -->
<!-- hitwebcounter Code START -->
<div class="right_nav">
<h2>List Of Students Admissions</h2>
<div class="operations_row">
<div class="search_box">
<form method="post">
<table> <tr><td>
<?php
echo createSelect('franchise_id', array('attrs'=> Array('size'=>1, 'class'=>'selectMenu', 'style'=>'width: auto; height: 35px; margin-right: 29px;', 'id'=> 'journal'),'options'=> $cats,'empty'=> 'All Students'));
//echo createSelect('franchisee', array('options'=> $cats, 'selected'=> $ctid, 'empty'=> 'All Students', 'attrs'=> array('id'=> 'sort_categ')))
?>
</td>
<td><input type="search" name="search_by" />
<input type="submit" name="search" value="Search" id="search" /></td></tr></table>
</form>
</div>
<a href="admission.php">New Admission</a></div>
<form method="post">
<button name="export-pdf">Export pdf</button>
</form>
<form method="post">
<button name="export-csv">Export csv</button>
</form>
<?php //print_r($courses);
echo $kt->output();
?>
<script type="text/javascript">
$(function(){
$('#journal').change(function(){
if(this.id=='journal')
this.form.submit();
});
});
</script>
<script type="text/javascript">
$(function(){
$('.actions_column .approve-link').click(function(){
return confirm("Are You sure to Approve Admission");
});
});
</script>
</div>
<!--right nav end -->
<div class="clear"></div>
<!--footer -->
<?php include ('../includes/footer_admin.php');?>
<style type="text/css">
input {
border: 1px solid black;
border-radius: 10px;
height: 35px;
width: 150px;
}
.search_box {
float: left;
width: auto;
}
#search
{
background: linear-gradient(to bottom, #01b0b8 0%, #08abb2 50%, #019da4 51%, #30c2c0 100%) repeat scroll 0 0 rgba(0, 0, 0, 0);
border-radius: 5px;
box-shadow: 1px 1px 2px #333;
color: #fff;
font-size: 12px;
font-weight: bold;
text-align: center;
width: 75px;
}
element.style {
width: auto;
height: 35px;
margin-right: 29px;
}
</style>
|