JezK
Edit File: 2021-09-27school_admin_access_app.php
<?php include_once("Config.php"); class adminaccess { private $conn; function __construct() { require_once dirname(__FILE__) . '/DbConnect.php'; // opening db connection $db = new DbConnect(); $this->conn = $db->connect(); } function student_name($id) { $sql="SELECT `student_firstname` , `student_rollno`,`student_lastname` FROM `ced_t_students` WHERE `student_id` = '".$id."' "; //echo $sql; $result=mysql_query($sql); /*while($row=mysql_fetch_array($result)) { $data[]=$row; }*/ $row=mysql_fetch_array($result); $data=$row['student_firstname']." ".$row['student_lastname']; //$data=$row['student_rollno']; return $data; } function student_rollnumber($id) { $sql="SELECT `student_rollno` FROM `ced_t_students` WHERE `student_id` = '".$id."' "; //echo $sql; $result=mysql_query($sql); $row=mysql_fetch_array($result); $data=$row['student_rollno']; return $data; } function classname($id) { $sql="SELECT `class_name` FROM `ced_t_class` WHERE `class_id` = '".$id."' "; //echo $sql; $result=mysql_query($sql); $row=mysql_fetch_array($result); $data=$row['class_name']; return $data; } function sectionname($class_id,$section_id) { $sql="SELECT `section_name` FROM `ced_t_sections` WHERE `section_id` = '".$section_id."' AND `class_id` = '".$class_id."' "; //echo $sql; $result=mysql_query($sql); $row=mysql_fetch_array($result); $data=$row['section_name']; return $data; } function get_subjectslists($class_id) { $sql="SELECT `subject_name` ,`subject_id` FROM `ced_t_subjects` s INNER JOIN `ced_t_class` c ON s.`class_category_id` = c.`class_category_id` WHERE s.`school_id` = c.`school_id` AND c.`class_id` ='".$class_id."'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data['subject_id']=$row['subject_id']; $data['subject_name']=$row['subject_name']; $data2[]=$data; } return $data2; } //// method is not in use function get_subjects_lists_nag($class_id,$section_id,$exam_id,$student_id,$school_id,$academic_id) { $sql="SELECT `class_category_id` FROM `ced_t_class` WHERE `class_id`='".$class_id."'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $sql="SELECT `subject_name` ,`subject_id` FROM `ced_t_subjects` where `class_category_id` ='".$row['class_category_id']."' and `school_id`='".$school_id."' and `academic_year_id`='".$academic_id."'"; /*$sql="SELECT m.`student_id`, m.`marks_secured`,m.`subject_id`,m.`status`,m.`grade`,t.`total_marks` FROM `ced_t_students_marks` as m inner join `ced_t_exam_timetable`as t on m.`subject_id`=t.`subject_id` and m.`exam_id`=t.`exam_id` where t.`class_id`='".$class_id."' and t.`section_id`='".$section_id."' and m.`student_id`='".$student_id."' and m.`exam_id`= '".$exam_id."' and t.`exam_id` = '".$exam_id."'"; //echo $sql;*/ $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['subject_id']=$row['subject_id']; $data['subject_name']=$this->getsubject_name($row['subject_id'],$school_id,$academic_id); /*$data['total_marks']=$row['total_marks']; $data['marks_secured']=$row['marks_secured']; $data['status']=$row['status']; $data['grade']=$row['grade'];*/ $marks=$this->loadexam_timetable_subject($class_id,$section_id,$row['subject_id'],$exam_id,$academic_id,$school_id); $data['total_marks']=$this->gettotal_marks($row['subject_id'],$exam_id,$class_id,$section_id); $marks_details=$this->getsecured_marks($row['subject_id'],$exam_id,$student_id,$academic_id); if($marks_details) { $data['marks_secured']=$marks_details['marks_secured']; $data['status']=$marks_details['status']; //$data['grade']=$marks['grade']; } else { $data['marks_secured']=""; $data['status']=""; //$data['grade']=$marks['grade']; } $data2[]=$data; } } else { $sql="SELECT `subject_id`,`total_marks` FROM `ced_t_exam_timetable` WHERE `class_id`='".$class_id."' and `section_id`='".$section_id."' and `exam_id`='".$exam_id."'"; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['subject_id']=$row['subject_id']; $data['subject_name']=$this->getsubject_name($row['subject_id'],$school_id,$academic_id); $data['total_marks']=$row['total_marks']; /*$secured_marks=$this->getsecured_marks($row['subject_id'],$exam_id,$student_id); if($secured_marks) { $data['marks_secured']=$secured_marks['marks_secured']; $data['status']=$secured_marks['status']; } else { $data['marks_secured']=""; $data['status']=""; }*/ $data2[]=$data; } } } return $data2; } function get_subjects_lists($class_id,$section_id,$exam_id,$student_id,$school_id,$academic_id) { $sql="SELECT `total_marks` ,`subject_id` FROM `ced_t_exam_timetable` where `class_id` =".(int)$class_id." and section_id=".(int)$section_id." and exam_id=".(int)$exam_id." and academic_year_id=".(int)$academic_id; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['subject_id']=$row['subject_id']; $data['subject_name']=$this->getsubject_name($row['subject_id'],$school_id,$academic_id); $data['total_marks']=$row['total_marks']; $marks_details=$this->getsecured_marks($row['subject_id'],$exam_id,$student_id,$academic_id); if($marks_details) { $data['marks_secured']=$marks_details['marks_secured']; $data['status']=$marks_details['status']; } else { $data['marks_secured']=""; $data['status']=""; } $data2[]=$data; } return $data2; } } function getthisStudentgrade($classid,$sec_id,$exname_id,$student_id,$school_id,$academic_id) { $qry="select student_grade_id,student_grade from ` ced_t_student_grades` where student_id='$student_id' and exam_id='$exname_id' and academic_year_id=".(int)$academic_id; $exe=mysql_query($qry); if(mysql_num_rows($exe)) { $res=mysql_fetch_array($exe); return $res['student_grade']; } else { return '0'; } } function getsecured_marks($subject_id,$exam_id,$student_id,$academic_id) { //$sql="SELECT `marks_secured`,`status` FROM `ced_t_students_marks` WHERE `student_id`='".$student_id."' and `exam_id`='".$exam_id."' and`subject_id`='".$subject_id."'"; $sql="SELECT `marks_secured`,`subject_id`,`status`,`grade`,`total_secured_marks` FROM `ced_t_students_marks` WHERE `exam_id`='".$exam_id."' and `student_id`='".$student_id."' and `subject_id`='".$subject_id."' and `academic_year_id`='".$academic_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $row=mysql_fetch_array($result); $data['marks_secured']=$row['marks_secured']; $data['status']=$row['status']; $data['grade']=$row['grade']; } else { $data=0; } return $data; } function gettotal_marks($subject_id,$exam_id,$class_id,$section_id) { $sql="SELECT `total_marks` FROM `ced_t_exam_timetable` WHERE `subject_id`='".$subject_id."' and `exam_id`='".$exam_id."' and `class_id`='".$class_id."' and `section_id`='".$section_id."'"; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $row=mysql_fetch_array($result); } return $row['total_marks']; } function get_classes($school_id,$academic_year_id) { $sql="SELECT `class_id` , `class_name` FROM `ced_t_class` where `school_id`='".$school_id."' and `academic_year_id`='".$academic_year_id."' order by class_order"; //echo $sql; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data[]=$row; } return $data; } function get_sections($class_id,$academic_id) { $sql="SELECT `section_id` , `section_name` FROM `ced_t_sections` WHERE `class_id` = '".$class_id."' and `academic_year_id`='".$academic_id."' order by section_id"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data['section_id']=$row['section_id']; $data['section_name']=$row['section_name']; $data2[]=$data; } return $data2; } function addexamination_schedule($exam_id,$subject_id,$exam_date,$exam_time,$duration_time,$class_id,$section_id,$academic_id,$user_id,$total_marks,$school_id) { $dateInput = explode('/',$exam_date); $date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $sql12="SELECT * FROM `ced_t_exam_timetable` WHERE `exam_id`='".$exam_id."' and `class_id`='".$class_id."' and `section_id`='".$section_id."' and `subject_id`='".$subject_id."' "; $result12=mysql_query($sql12); if(mysql_num_rows($result12)>0) { $sql="UPDATE `ced_t_exam_timetable` SET `exam_date`='".$date."',`exam_time`='".$exam_time."',`exam_duration`='".$duration_time."', `updated_by`='".$user_id."',`updated_on`=CURDATE(), `total_marks`='".$total_marks."' WHERE `class_id`='".$class_id."' AND `section_id`='".$section_id."' AND `exam_id`='".$exam_id."' AND `subject_id`='".$subject_id."' AND `academic_year_id`='".$academic_id."'"; mysql_query($sql); $result=mysql_affected_rows(); } else { $sql="INSERT INTO `ced_t_exam_timetable`( `subject_id`, `exam_date`, `exam_time`, `exam_duration`, `class_id`, `section_id`, `exam_id`, `academic_year_id`,`total_marks`,`created_by`,`created_on`) VALUES ('".$subject_id."','".$date."','".$exam_time."','".$duration_time."','".$class_id."','".$section_id."','".$exam_id."','".$academic_id."','".$total_marks."','".$user_id."',CURDATE())"; mysql_query($sql); $result=mysql_insert_id(); } if($result) return 1; else return 0; } function addgrade_students($exam_id,$student_id,$grade,$academic_id,$user_id) { $sql="SELECT * FROM ` ced_t_student_grades` WHERE `exam_id`='".$exam_id."' AND `student_id`='".$student_id."' and academic_year_id=".(int)$academic_id; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $sql="UPDATE ` ced_t_student_grades` SET `student_grade`='".$grade."',`updated_on`=CURDATE() ,`updated_by`='".$user_id."' WHERE `exam_id`='".$exam_id."' and `student_id`='".$student_id."' and `academic_year_id`='".$academic_id."'"; mysql_query($sql); $result=mysql_affected_rows(); } else { $sql="INSERT INTO ` ced_t_student_grades`( `exam_id`, `student_id`, `student_grade`, `academic_year_id`,`created_on`,`created_by`) VALUES ('".$exam_id."','".$student_id."','".$grade."','".$academic_id."',CURDATE(),'".$user_id."')"; mysql_query($sql); $result=mysql_insert_id(); } return $error=1; } function addgrade_students_and_push($exam_id,$student_id,$grade,$academic_id,$user_id,$ename) { $sql="SELECT * FROM ` ced_t_student_grades` WHERE `exam_id`='".$exam_id."' AND `student_id`='".$student_id."' and academic_year_id=".(int)$academic_id; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $sql="UPDATE ` ced_t_student_grades` SET `student_grade`='".$grade."',`updated_by`='".$user_id."' WHERE `exam_id`='".$exam_id."' and `student_id`='".$student_id."' and `academic_year_id`='".$academic_id."'"; mysql_query($sql); $result=mysql_affected_rows(); } else { $sql="INSERT INTO ` ced_t_student_grades`( `exam_id`, `student_id`, `student_grade`, `academic_year_id`,`created_on`,`created_by`) VALUES ('".$exam_id."','".$student_id."','".$grade."','".$academic_id."',CURDATE(),'".$user_id."')"; mysql_query($sql); $result=mysql_insert_id(); } if($result && $grade!='') { $check_parents_data = $this->check_parent_data($student_id); if(!empty($check_parents_data)) { $msg['type'] = "exam_res"; $msg['exam_id']=$exam_id; $msg['acadamic_id']=$academic_id; foreach($check_parents_data as $key=>$val) { $registatoin_ids = $val['device_id']; $msg['message'] = "Grade for ".$ename." for ".$val['student_firstname']." ".$val['student_lastname']." for AY ".$_SESSION['child']['choosen_year_name']." has been updated"; $msg['student_id'] = $val['student_id']; $noteins="insert into ced_t_notifications set notify_name='".$msg['message']."',student_id=".(int)$val['student_id'].",notify_type='exam_res',read_status=1,general_column1='".$exam_id."',created_on='".date('Y-m-d')."',general_column2='".$academic_id."'"; mysql_query($noteins); $nstate=$this->getNotestate($val['authenticate_id']); if($registatoin_ids!='' && $nstate=='1') $resultss = $this->send_notice($registatoin_ids, $msg); } } $error=1; } else { $error=2; } return $error; } function save_student_marks($exam_id,$student_id,$subject_id,$secured_marks,$exam_status,$grade,$academic_id,$total_secured_marks,$user_id) { $exname=$this->getexam_name($exam_id); $sql2="SELECT * FROM `ced_t_students_marks` WHERE `exam_id`='".$exam_id."' and `student_id`='".$student_id."' and `subject_id`='".$subject_id."' "; $result2=mysql_query($sql2); if(mysql_num_rows($result2)>0) { $sql="UPDATE `ced_t_students_marks` SET `marks_secured`='".$secured_marks."',`status`='".$exam_status."',`grade`='".$grade."' where `exam_id`='".$exam_id."' and `student_id`='".$student_id."' and `academic_year_id`='".$academic_id."' and `subject_id`='".$subject_id."'"; mysql_query($sql); $result=mysql_affected_rows(); } else { $sql="INSERT INTO `ced_t_students_marks`( `exam_id`, `student_id`, `marks_secured`, `subject_id`, `status`, `grade`, `created_by`,`created_on`, `academic_year_id`,`total_secured_marks`) VALUES ('".$exam_id."','".$student_id."','".$secured_marks."','".$subject_id."','".$exam_status."','".$grade."','".$user_id."',CURDATE(),'".$academic_id."','".$total_secured_marks."')"; mysql_query($sql); $result=mysql_insert_id(); } if($result) { return 2; } /*if($result) { $check_parents_data = $this->check_parent_data($student_id); if(!empty($check_parents_data)) { $msg['type'] = "exam_res"; $msg['message'] = "Marks has been added"; $msg['exam_id']=$exam_id; $msg['acadamic_id']=$academic_id; foreach($check_parents_data as $key=>$val) { $registatoin_ids = $val['device_id']; $msg['student_id'] = $val['student_id']; if($registatoin_ids!='') $resultss = $this->send_notice($registatoin_ids, $msg); } } }*/ return 1; } function getexam_name($examid) { $sql="select exam_name from ced_t_exam_names where exam_id=".(int)$examid; $exe=mysql_query($sql); $res=mysql_fetch_array($exe); return $res['exam_name']; } function get_students($class_id,$section_id,$school_id,$academic_id,$exam_id,$subject_id) { $sql="SELECT * FROM `ced_t_exam_timetable` WHERE `subject_id`='".$subject_id."' and `class_id`='".$class_id."' and `section_id`='".$section_id."' and `exam_id`='".$exam_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $sql="SELECT `student_rollno` , `student_id`,`student_firstname` , `student_lastname` FROM `ced_t_students` WHERE `class_id` = '".$class_id."' AND `section_id` = '".$section_id."' AND `academic_year_id` = '".$academic_id."' AND `school_id` = '".$school_id."' and status=1"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { //$daa = 1; while($row=mysql_fetch_array($result)) { $data['student_id']=$row['student_id']; $data['student_name']=$row['student_firstname']." ".$row['student_lastname']; $data['student_rollno']=$row['student_rollno']; $data['total_marks']=$this->gettotal_marks($subject_id,$exam_id,$class_id,$section_id); $marks_details=$this->getsecured_marks($subject_id,$exam_id,$row['student_id'],$academic_id); if($marks_details) { //$data['total_marks']=$marks_details['total_marks']; $data['status']=$marks_details['status']; $data['marks_secured']=$marks_details['marks_secured']; } else { $data['status']=""; $data['marks_secured']=""; } $data2[]=$data; } } } else { $data2=""; } return $data2; } function get_students2($class_id,$section_id,$school_id,$academic_id) { $sql=" SELECT `student_rollno` , `class_id`,`section_id` ,`student_id`,`student_firstname` , `student_lastname` FROM `ced_t_students` WHERE `class_id` = '".$class_id."' AND `section_id` = '".$section_id."' AND `academic_year_id` = '".$academic_id."' AND `school_id` = '".$school_id."' "; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['student_rollno']=$row['student_rollno']; $data['student_id']=$row['student_id']; $data['student_name']=$row['student_firstname']." ".$row['student_lastname']; $data['class_name']=$this->classname($row['class_id']); $data['section_name']=$this->sectionname($row['class_id'],$row['section_id']); $data2[]=$data; } } else { $data2=""; } return $data2; } /*function get_students_for_routes($class_id,$section_id,$school_id,$academic_id)//DEPRECIATED { $sql=" SELECT s.student_rollno , s.class_id,s.section_id ,s.student_address,s.student_id,s.student_firstname ,s.student_lastname,r.route_id,r.route_stop_id FROM ced_t_students s left join ced_t_students_routes r on s.student_id=r.student_id WHERE s.class_id =".(int)$class_id." AND s.section_id =".(int)$section_id." AND s.academic_year_id=".(int)$academic_id." AND s.school_id =".(int)$school_id." and s.status=1 order by s.student_id"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['student_rollno']=$row['student_rollno']; $data['student_id']=$row['student_id']; $data['student_name']=$row['student_firstname']." ".$row['student_lastname']; $data['class_name']=$this->classname($row['class_id']); $data['section_name']=$this->sectionname($row['class_id'],$row['section_id']); $data['route_id']=$row['route_id']; $data['student_address']=$row['student_address']; $data['route_stop']=$row['route_stop_id']; $data2[]=$data; } } else { $data2=""; } return $data2; }*/ function get_routemaps_ofDriver($schoolid,$acdid,$route_id) { $dt2=date('Y-m-d'); $dt1=$prev_date = date('Y-m-d', strtotime($dt2 .' -5 day')); $qry="select s.staff_name,s.staff_pic,tr.Created_on,tr.start_time,tr.end_time,tr.map_img from ced_t_school_staff s left join ced_t_trip_history tr on s.staff_id=tr.staff_id where tr.Created_on between '".$dt1."' and '".$dt2."' and tr.route_id=".(int)$route_id." and s.status=1 order by tr.trip_id, tr.Created_on desc"; $exe=mysql_query($qry); if(mysql_num_rows($exe)>0) { while($row=mysql_fetch_assoc($exe)) { $rec[]=$row; } } return $rec; } function get_routemaps_ofDrivergeos($schoolid,$acdid,$route_id,$driver_id) { //$dt2=date('Y-m-d'); //$dt1=$prev_date = date('Y-m-d', strtotime($dt2 .' -5 day')); $dt1 = "2016-01-11"; $dt2 = "2016-01-12"; // $qry="select s.staff_name,s.staff_pic,tr.* from ced_t_school_staff s left join ced_t_geovalues tr on s.staff_id=tr.driver_id where tr.taken_at between '".$dt1."' and '".$dt2."' and tr.route_id=".(int)$route_id." and tr.driver_id=".(int)$driver_id." and s.status=1 "; $qry="select s.staff_name,s.staff_pic,tr.* from ced_t_school_staff s left join ced_t_geovalues tr on s.staff_id=tr.driver_id where tr.taken_at between '".$dt1."' and '".$dt2."' and tr.route_id=2 and tr.driver_id=7 and s.status=1 "; echo $qry; $exe=mysql_query($qry); if(mysql_num_rows($exe)>0) { while($row=mysql_fetch_assoc($exe)) { $rec[]=$row; } } return $rec; } function get_students_for_routes($class_id,$section_id,$route_id,$school_id,$academic_id) { $sql=" SELECT student_rollno , class_id,section_id ,student_address,student_id,student_firstname ,student_lastname FROM ced_t_students WHERE class_id =".(int)$class_id." AND section_id =".(int)$section_id." AND academic_year_id=".(int)$academic_id." AND school_id =".(int)$school_id." and status=1 order by student_id"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['student_rollno']=$row['student_rollno']; $data['student_id']=$row['student_id']; $data['student_name']=$row['student_firstname']." ".$row['student_lastname']; $data['class_name']=$this->classname($row['class_id']); $data['section_name']=$this->sectionname($row['class_id'],$row['section_id']); $data['student_address']=$row['student_address']; $sub_qry="select route_id,route_stop_id from ced_t_students_routes where student_id=".(int)$row['student_id']." and route_id=".(int)$route_id." and academic_year_id=".(int)$academic_id; $sqexe=mysql_query($sub_qry); if(mysql_num_rows($sqexe)) { $rec=mysql_fetch_array($sqexe); $data['route_id']=$rec['route_id']; $data['route_stop']=$rec['route_stop_id']; } else { $data['route_id']=''; $data['route_stop']=''; } $data2[]=$data; } } else { $data2=""; } return $data2; } function get_studentsto_grade($class_id,$section_id,$exam_id,$school_id,$academic_id) { //$sql=" SELECT g.`student_id`,g.`student_grade`,s.`student_rollno` ,s.`student_firstname`, s.`student_lastname` FROM ` ced_t_student_grades` as g inner join ced_t_students as s on s.`student_id` = g.`student_id` where s.`class_id` = '".$class_id."' and s.`section_id` = '".$section_id."' and s.`school_id` = '".$school_id."' and s.`academic_year_id` = '".$academic_id."' and g.`exam_id`='".$exam_id."' "; $sql="select student_id, student_firstname,student_lastname,student_rollno from ced_t_students where class_id='$class_id' and section_id='$section_id' and school_id='$school_id' and academic_year_id='$academic_id' and status=1"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $qry="select student_grade from ` ced_t_student_grades` where student_id='".$row[student_id]."' and exam_id='".$exam_id."' and academic_year_id=".(int)$academic_id; $exe=mysql_query($qry); if(mysql_num_rows($exe)>0) { $rec=mysql_fetch_array($exe); $data['student_grade']=$rec['student_grade']; } else $data['student_grade']=''; $data['total_secured']=$this->gettotal_marksecured($exam_id,$row['student_id'],$academic_id); $data['student_rollno']=$row['student_rollno']; $data['student_id']=$row['student_id']; $data['student_name']=$row['student_firstname']." ".$row['student_lastname']; //$data['student_grade']=$row['student_grade']; $data2[]=$data; } } else { $sql=" SELECT `student_rollno` , `class_id`,`section_id` ,`student_id`,`student_firstname` , `student_lastname` FROM `ced_t_students` WHERE `class_id` = '".$class_id."' AND `section_id` = '".$section_id."' AND `academic_year_id` = '".$academic_id."' AND `school_id` = '".$school_id."' "; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['student_rollno']=$row['student_rollno']; $data['student_id']=$row['student_id']; $data['student_name']=$row['student_firstname']." ".$row['student_lastname']; $data['class_name']=$this->classname($row['class_id']); $data['section_name']=$this->sectionname($row['class_id'],$row['section_id']); $data2[]=$data; } } } return $data2; } function gettotal_marksecured($exam_id,$student_id,$academic_id) { $marks=0; $sql="select marks_secured from ced_t_students_marks where exam_id=".(int)$exam_id." and student_id=".(int)$student_id." and academic_year_id=".(int)$academic_id; $exe=mysql_query($sql); if(mysql_num_rows($exe)) { while($res=mysql_fetch_array($exe)) $marks+=(int)$res['marks_secured']; } return $marks; } function get_current_academicyear_id($chosen_academic_id,$school_id) { $sql="SELECT `academic_startdate`,`academic_enddate` FROM `ced_t_academicyear` WHERE `academic_id`='".$chosen_academic_id."' and `school_id`='".$school_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $row=mysql_fetch_array($result); $data['start_date']=$row['academic_startdate']; $data['end_date']=$row['academic_enddate']; } return $data; } function addstudents_route($student_id,$route_id,$stop_id,$academic_id) { for($i=0;$i<count($student_id);$i++) { $stp=$student_id[$i]; //$sql="SELECT * FROM `ced_t_students_routes` WHERE `student_id`='".$student_id[$i]."' and `route_id`='".$route_id."' and academic_year_id=".(int)$academic_id; $sql="SELECT * FROM `ced_t_students_routes` WHERE `student_id`='".$student_id[$i]."' and `route_id`='".$route_id."' and academic_year_id=".(int)$academic_id; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $sql="UPDATE `ced_t_students_routes` SET `route_stop_id`='".$stop_id[$stp]."' WHERE `student_id`='".$student_id[$i]."' and `route_id`='".$route_id."' and academic_year_id=".(int)$academic_id; } else { $sql="INSERT INTO `ced_t_students_routes`( `student_id`, `academic_year_id`, `route_id`, `route_stop_id`, `created_on`) VALUES ('".$student_id[$i]."','".$academic_id."','".$route_id."','".$stop_id[$stp]."',CURDATE())"; } $result=mysql_query($sql); } return 'success'; } function staff_routes_info($route_id,$school_id,$academic_id) { $sql="SELECT `staff_name`,sf.`staff_id`,`staff_address`,`staff_mobile` FROM `ced_t_school_staff` sf inner join `ced_t_staff_routes` r on sf.`staff_id`=r.`staff_id` where r.`route_id`='".$route_id."' and sf.`academic_year_id`='".$academic_id."' and sf.`school_id`='".$school_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['staff_name']=$row['staff_name']; $data['staff_address']=$row['staff_address']; $data['staff_mobile']=$row['staff_mobile']; $data2[]=$data; } } else { $data2=""; } return $data2; } function student_names($student_ids) { $sql="SELECT `student_firstname` , `student_lastname` FROM `ced_t_students` WHERE `student_id` in ('".$student_ids."') "; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data[]=$row['student_firstname']." ".$row['student_lastname']; } $names = implode(",",$data); return $names; } function route_stops($route_id,$academic_id) { $i=1; $sql="SELECT `route_stop_id`,`route_stop_name` FROM `ced_t_route_stops` WHERE `route_id`='".$route_id."' and `academic_year_id`='".$academic_id."' order by route_stop_id"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { if($i!=2) { $data['route_stop_id']=$row['route_stop_id']; $data['route_stop_name']=$row['route_stop_name']; $data2[]=$data; } else { $dest['route_stop_id']=$row['route_stop_id']; $dest['route_stop_name']=$row['route_stop_name']; } $i++; } $data2[]=$dest; } return $data2; } function getroute_stops_lists($route_id,$academic_id) { $sql="SELECT `route_stop_id` ,`route_stop_name` FROM `ced_t_route_stops` WHERE `route_id`='".$route_id."' and `academic_year_id`='".$academic_id."'"; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['route_stop_id']=$row['route_stop_id']; $data['route_stop_name']=$row['route_stop_name']; $data2[]=$data; } } //print_r($data2); return $data2; } function add_students_marks($class_id,$section_id,$school_id,$academic_id,$exam_name_id,$student_id) { $sql="select exam_id,subject_id,total_marks from ced_t_exam_timetable where class_id=".(int)$class_id." and section_id=".(int)$section_id." and academic_year_id=".(int)$academic_id." and exam_id=".(int)$exam_name_id; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($rec=mysql_fetch_array($result)) { $qry="select student_marks_id,exam_id,marks_secured,status from ced_t_students_marks where student_id=".(int)$student_id." and exam_id=".(int)$exam_name_id." and subject_id=".(int)$rec['subject_id']; $exe=mysql_query($qry); if(mysql_num_rows($exe)) { $row=mysql_fetch_array($exe); $data['marks_secured']=$row['marks_secured']; $data['status']=$row['status']; $data['student_marks_id']=$row['student_marks_id']; } else { $data['marks_secured']='N/A'; $data['status']='N/A'; $data['student_marks_id']=0; } if($data['status']==1) $data['status']="P"; else if($data['status']==2) $data['status']="F"; else $data['status']="N/A"; $data['student_id']=$student_id; $data['exam_id']=$rec['exam_id']; $data['student_rollno']=$this->student_rollnumber($student_id); $data['subject_id']=$rec['subject_id']; $data['total_marks']=$rec['total_marks']; $data['student_name']=$this->student_name($student_id); $data['subject_name']=$this->getsubject_name($rec['subject_id'],$school_id,$academic_id); /*$grade=$this->getStudent_Grade($rec['exam_id'],$student_id,$academic_id); if($grade) { $data['grade']=$grade; } else { $data['grade']="N/A"; }*/ $data2[]=$data; } } return $data2; } function getStudent_Grade($exam_id,$student_id,$academic_id) { $sql="SELECT `student_grade` FROM ` ced_t_student_grades` WHERE `exam_id`='".$exam_id."' AND `academic_year_id`='".$academic_id."' AND `student_id`='".$student_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $row=mysql_fetch_array($result); } return $row['student_grade']; } function getsubjects($class_id,$school_id,$academic_id) { $sql="SELECT `subject_id` , `subject_name` FROM `ced_t_subjects` sub INNER JOIN `ced_t_class` cls ON sub.`class_category_id` = cls.`class_category_id` AND sub.`school_id` ='".$school_id."' AND sub.`academic_year_id` ='".$academic_id."' AND `class_id` ='".$class_id."' and sub.subject_status=1"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data['subject_id']=$row['subject_id']; $data['subject_name']=$row['subject_name']; $data2[]=$data; } return $data2; } function adding_student_marks($exam_id,$subject_id,$student_id,$secured_marks,$status,$academic_id,$user_id) { $sql2="SELECT * FROM `ced_t_students_marks` WHERE `exam_id`='".$exam_id."' and `student_id`='".$student_id."' and `academic_year_id`='".$academic_id."' and subject_id=".(int)$subject_id; $result2=mysql_query($sql2); if(mysql_num_rows($result2)>0) { $sql="UPDATE `ced_t_students_marks` SET `marks_secured`='".$secured_marks."',`status` ='".$status."' where `exam_id`='".$exam_id."' and `student_id`='".$student_id."' and `academic_year_id`='".$academic_id."' and `subject_id`='".$subject_id."'"; mysql_query($sql); $result=mysql_affected_rows(); } else { $sql="INSERT INTO `ced_t_students_marks`( `exam_id`, `student_id`, `marks_secured`, `subject_id`, `status`, `created_by`, `created_on` ,`academic_year_id`) VALUES ('".$exam_id."','".$student_id."','".$secured_marks."','".$subject_id."','".$status."','".$user_id."',CURDATE(),'".$academic_id."')"; mysql_query($sql); $result=mysql_insert_id(); } //echo $sql; if($result) { $check_parents_data = $this->check_parent_data($student_id); if(!empty($check_parents_data)) { $msg['type'] = "exam_res"; $ename=$this->getexam_name($exam_id); $msg['exam_id']=$exam_id; $msg['acadamic_id']=$academic_id; foreach($check_parents_data as $key=>$val) { $registatoin_ids = $val['device_id']; $msg['message'] = "Marks for ".$ename." for ".$val['student_firstname']." ".$val['student_lastname']." for AY ".$_SESSION['child']['choosen_year_name']." has been updated"; $msg['student_id'] = $val['student_id']; $noteins="insert into ced_t_notifications set notify_name='".$msg['message']."',student_id=".(int)$student_id.",notify_type='exam_res',read_status=1,general_column1='".$exam_id."',created_on='".date('Y-m-d')."',general_column2='".$academic_id."'"; mysql_query($noteins); $nstate=$this->getNotestate($val['authenticate_id']); if($registatoin_ids!='' && $nstate=='1') $resultss = $this->send_notice($registatoin_ids, $msg); } } } return $error=1; } function update_student_marks($exam_id,$subject_id,$student_id,$secured_marks,$status,$academic_id) { $sql="UPDATE `ced_t_students_marks` SET `marks_secured` ='".$secured_marks."' ,`status`='".$status."'WHERE `student_id` ='".$student_id."' AND `subject_id` ='".$subject_id."' AND `exam_id` ='".$exam_id."' AND `academic_year_id` ='".$academic_id."' "; //echo $sql; $result=mysql_query($sql); if($result) { $error=1; } else { $error=0; } return $error; } function getsubject_name($subject_id,$school_id,$academic_id) { $sql="SELECT `subject_name` FROM `ced_t_subjects` WHERE `subject_id` ='".$subject_id."' and `school_id`='".$school_id."' and `academic_year_id`='".$academic_id."'"; //echo $sql; $result=mysql_query($sql); $row=mysql_fetch_array($result); return $row['subject_name']; } function update_student_onroute($student_id,$route_id,$route_stop_id,$school_id,$academic_id,$user_id) { $sql="UPDATE `ced_t_students_routes` SET `route_id` ='".$route_id."',`route_stop_id` ='".$route_stop_id."',Updated_by='$user_id' WHERE `student_route_id` =".$student_id; $result=mysql_query($sql); return 1; } function exam_name_details($school_id,$academic_id) { $sql="SELECT `exam_name` , `exam_id` FROM `ced_t_exam_names` WHERE `school_id` ='".$school_id."' AND `academic_year_id` ='".$academic_id."' order by exam_id"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data['exam_name']=$row['exam_name']; $data['exam_id']=$row['exam_id']; $data2[]=$data; } return $data2; } function exam_timetable($class_id,$section_id,$school_id,$academic_id,$exam_id) { if($section_id == 'all') { $con = ""; } else { $con = "and `section_id` ='".$section_id."' "; } $sql="SELECT `timetable_id` , `total_marks`, `class_id`,`section_id`,`subject_id` , `exam_date` , `exam_time` , `exam_duration` , `exam_id` FROM `ced_t_exam_timetable` WHERE `class_id` ='".$class_id."' AND `exam_id` ='".$exam_id."' AND `academic_year_id` ='".$academic_id."' ".$con; //echo $sql; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data['timetable_id']=$row['timetable_id']; $data['exam_date']=$row['exam_date']; $data['exam_id']=$row['exam_id']; $data['subject_id']=$row['subject_id']; $data['exam_time']=$row['exam_time']; $data['exam_duration']=$row['exam_duration']; $data['total_marks']=$row['total_marks']; $data['class_id']=$row['class_id']; $data['section_id']=$row['section_id']; $data['exam_subject']=$this->getsubject_name($row['subject_id'],$school_id,$academic_id); $data2[]=$data; } return $data2; } function loadexam_timetable($class_id,$section_id,$school_id,$academic_id,$exam_id) { $sql="SELECT `class_category_id` FROM `ced_t_class` WHERE `class_id`='".$class_id."'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $sql="SELECT `subject_name` ,`subject_id` FROM `ced_t_subjects` where `class_category_id` ='".$row['class_category_id']."' and `school_id`='".$school_id."' and `academic_year_id`='".$academic_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['subject_id']=$row['subject_id']; $data['exam_subject']=$row['subject_name']; $marks=$this->loadexam_timetable_subject($class_id,$section_id,$row['subject_id'],$exam_id,$academic_id,$school_id); $data['total_marks'] =$marks['total_marks']; $data['exam_date'] =$marks['exam_date']; $data['exam_duration']=$marks['exam_duration']; $data['exam_time'] =$marks['exam_time']; $data2[]=$data; } } return $data2; } function loadexam_timetable_subject($class_id,$section_id,$subject_id,$exam_id,$academic_id,$school_id) { //if($section_id == "all") //{ // $con = ''; //} //else //{ $con = "and `section_id`='".$section_id."' "; //} $sql="SELECT `total_marks` ,`exam_date`,`exam_duration`,`exam_time`,`subject_id` FROM `ced_t_exam_timetable` WHERE `subject_id`='".$subject_id."' and `exam_id`='".$exam_id."' and `class_id`='".$class_id."' and `academic_year_id`='".$academic_id."' ".$con; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['subject_id']=$row['subject_id']; $data['total_marks']=$row['total_marks']; $data['exam_date']=$row['exam_date']; $data['exam_duration']=$row['exam_duration']; $data['exam_time']=$row['exam_time']; $data['exam_subject']=$this->getsubject_name($row['subject_id'],$school_id,$academic_id);; } } return $data; } function delete_exam_schedule($exam_timetable_id,$class_id,$section_id,$exam_id) { $sql = "SELECT m.`subject_id` ,m.`marks_secured`,m.`status`FROM `ced_t_students_marks` as m inner join `ced_t_exam_timetable` as t on t.`exam_id`=m.`exam_id` where t.`class_id`='".$class_id."' and t.`section_id`='".$section_id."' and t.`exam_id`='".$exam_id."' and m.`exam_id`='".$exam_id."' "; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $error=3; } else { $sql="DELETE FROM `ced_t_exam_timetable` WHERE `timetable_id`='".$exam_timetable_id."' "; //echo $sql; $result=mysql_query($sql); if($result) { //echo 'deleted'; $error=1; } else { $error=2; } } return $error; } function settigs_change_password($email,$current_password,$new_password,$school_id,$user_id) { $sql="SELECT * FROM `ced_t_authentication_details` WHERE `email`='".$email."' and `password`='".$current_password."' and `authenticate_id`='".$user_id."' and `school_admin_access`='1' and `school_id`='".$school_id."' "; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $sql2="UPDATE `ced_t_authentication_details` SET `password`='".$new_password."' where `email`='".$email."' "; $result2=mysql_query($sql2); if($result2) { $error=1; } else { $error=2; } } return $error; } function school_students_routes($school_id,$academic_id) { $sql="SELECT `route_id`,`route_number`,`source_name`,`destination_name` FROM `ced_t_routes` WHERE `school_id`='".$school_id."' and `academic_year_id`='".$academic_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['route_id']=$row['route_id']; $data['route_name']=$row['route_number']." (".$row['source_name'].'-'.$row['destination_name'].")"; $data2[]=$data; } } else { $data2=""; } return $data2; } function school_staff_driver($school_id,$academic_id) { $sql="SELECT `staff_id`,`staff_name` FROM `ced_t_school_staff` WHERE `school_id`='".$school_id."' and `academic_year_id`='".$academic_id."' and staff_type = 2 and auth_ref != 0"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['staff_id']=$row['staff_id']; $data['staff_name']=$row['staff_name']; $data2[]=$data; } } else { $data2=""; } return $data2; } function school_students_routes_info($route_id,$academic_id) { $sql="SELECT s.`student_id`,s.`student_firstname`,s.`student_lastname`,s.`class_id`,s.`section_id`,cr.`route_stop_name` FROM `ced_t_students` s inner join `ced_t_students_routes` sr on s.`student_id`=sr.`student_id` inner join `ced_t_route_stops` cr on sr.`route_stop_id`=cr.`route_stop_id` and sr.`route_id`='".$route_id."' and sr.`academic_year_id`='".$academic_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['student_rollno']=$row['student_rollno']; $data['student_id']=$row['student_id']; $data['class_id']=$row['class_id']; $data['section_id']=$row['section_id']; $data['route_stop_name']=$row['route_stop_name']; $data['student_name']=$row['student_firstname']." ".$row['student_lastname']; $data['class_name']=$this->classname($row['class_id']); $data['section_name']=$this->sectionname($row['class_id'],$row['section_id']); $data2[]=$data; } } else { $data2=""; } return $data2; } function getstudent_ids($class_id,$section_id) { $sql="SELECT `student_id` FROM `ced_t_students` WHERE `class_id`='".$class_id."' and `section_id`='".$section_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data[]=$row['student_id']; } } return $data; } function attendance_dates($month,$class_id,$section_id,$school_id,$academic_id) { $sql="SELECT a.`attendance_date` FROM `ced_t_attendance` a inner join `ced_t_students` s on s.`student_id`=a.`student_id` and s.`class_id`='".$class_id."' and s.`academic_year_id`='".$academic_id."' and s.`school_id`='".$school_id."' and s.`section_id`='".$section_id."' and month(`attendance_date`)='".$month."' and year(`attendance_date`)= year(CURDATE()) group by `attendance_date`"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data[]=$row['attendance_date']; } } return $data; } function view_examname($school_id,$academic_id) { $sql2="select * from ced_t_exam_names where school_id='".$school_id."' and academic_year_id='".$academic_id."' order by exam_id asc"; //echo $sql2; $result2=mysql_query($sql2); while($row=mysql_fetch_array($result2)) { $data[]=$row; } return $data; } function adding_exam_names($school_id,$academic_id,$exname,$admin_id) { $sql="SELECT * FROM `ced_t_exam_names` WHERE `exam_name`='".$exname."' and `academic_year_id`='".$academic_id."' and `school_id`='".$school_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $data=1; } else { $sql=" INSERT INTO `ced_t_exam_names`(`exam_name`, `school_id`, `academic_year_id`, `created_by`, `created_on`) VALUES ('".$exname."','".$school_id."','".$academic_id."','".$admin_id."',CURDATE())"; $result=mysql_query($sql); if($result) { $data=2; } else { $data=3; } } return $data; } function edit_exam_names($edit_name,$admin_id,$exam_id,$school_id,$academic_id) { $sql="SELECT * FROM `ced_t_exam_names` WHERE `exam_name`='".$edit_name."' and `academic_year_id`='".$academic_id."' and `school_id`='".$school_id."' and exam_id<>'$exam_id'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $error=2; } else { $sql="UPDATE `ced_t_exam_names` SET `exam_name`='".$edit_name."',`updated_by`='".$admin_id."',`updated_on`=CURDATE() WHERE `exam_id`='".$exam_id."'"; //echo $sql; $result=mysql_query($sql); if($result) { $error=1; } else { $error=0; } } return $error; } function delete_examname($id) { $sql="SELECT * FROM `ced_t_exam_timetable` WHERE `exam_id`='".$id."' "; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $error=2; } else { $sql="delete from ced_t_exam_names where exam_id='".$id."'"; $result=mysql_query($sql); if($result) { $error=1; } else { $error=0; } } return $error; } function student_score_details($student_id,$class_id,$section_id,$school_id,$academic_id) { $people=array(); $subjectsd=array(); $subjects2d=array(); $examsd=array(); $sql="SELECT s.`subject_id` ,s.`subject_name` FROM `ced_t_subjects` s inner join `ced_t_class` c on s.`class_category_id`=c.`class_category_id` and c.`class_id`='".$class_id."' and s.`school_id`=c.`school_id` and s.`school_id`='".$school_id."' "; $result=mysql_query($sql); while($info=mysql_fetch_array($result)) { $subjects[]=$info['subject_id']; $subjects2[]=$info['subject_name']; } $sql3="SELECT `exam_id` FROM `ced_t_exam_names` WHERE `school_id` ='".$school_id."' AND `academic_year_id` ='".$academic_id."'"; $result3=mysql_query($sql3); while($row=mysql_fetch_array($result3)) { $exams[]=$row['exam_id']; } for($i=0;$i<count($subjects);$i++) { for($j=0;$j<count($exams);$j++) { $marks_result=$this->exam_marksof_student($class_id,$section_id,$subjects[$i],$exams[$j]); if($marks_result==1) { $sql2="SELECT sub.`subject_id` , sub.`subject_name` , e.`exam_id` , m.`marks_secured` FROM `ced_t_subjects` sub INNER JOIN `ced_t_students_marks` m ON sub.`subject_id` = m.`subject_id` INNER JOIN `ced_t_exam_names` e ON m.`exam_id` = e.`exam_id` AND m.`student_id` ='".$student_id."' and m.`subject_id`= '".$subjects[$i]."' and m.`exam_id`='".$exams[$j]."' "; $result2=mysql_query($sql2); if(mysql_num_rows($result2) > 0) { $row=mysql_fetch_array($result2); //$data['subject_name']=$row['subject_name']; $data['subject_id']=$subjects[$i]; $data['exam_id']=$exams[$j]; $exam_name=$this->get_exam_name($data['exam_id']); if (in_array($exam_name, $people, true)) { } else { $people[]=$exam_name; } $data['marks_secured']=$row['marks_secured']; $data2[]=$data; //---------------------------------------- if (in_array($subjects[$i], $subjectsd, true)) { } else { $subjectsd[]=$subjects[$i]; } if (in_array($subjects2[$i], $subjects2d, true)) { } else { $subjects2d[]=$subjects2[$i]; } if (in_array($exams[$j], $examsd, true)) { } else { $examsd[]=$exams[$j]; } } } } } $merge['subjects']=$subjectsd; $merge['subjects_list']=$subjects2d; $merge['exames']=$examsd; $merge['marks']=$data2; $merge['exam_names']=$people; $merge['total_marks']=$this->get_totalmarks($subjects,$exams,$student_id); return $merge; } /////////////////////////////////////////////////////////////////////////////////////////////////////////// function student_subjects($student_id,$class_id,$section_id,$school_id,$academic_id) { $qry="select subject_id, subject_name from ced_t_subjects s inner join ced_t_class c on c.class_category_id=s.class_category_id where c.class_id=".(int)$class_id." and s.school_id=".(int)$school_id." and s.academic_year_id=".(int)$academic_id; $exe=mysql_query($qry); if(mysql_num_rows($exe)) { while($row=mysql_fetch_assoc($exe)) { $rec[]=$row; } return $rec; } } function student_exams($student_id,$class_id,$section_id,$school_id,$academic_id) { $qry="select exam_id,exam_name from ced_t_exam_names where school_id=".(int)$school_id." and academic_year_id=".(int)$academic_id." order by exam_id"; $exe=mysql_query($qry); if(mysql_num_rows($exe)) { while($row=mysql_fetch_assoc($exe)) { $rec[]=$row; } return $rec; } } function get_subject_marks($exam_id,$subject_id,$student_id,$schoolid,$academic_id) { $sql="select total_marks from ced_t_exam_timetable where subject_id=".(int)$subject_id." and exam_id=".(int)$exam_id." and academic_year_id=".(int)$academic_id; //$qry="select t.total_marks,e.marks_secured,e.status from ced_t_students_marks e inner join ced_t_exam_timetable t on t.exam_id=e.exam_id where e.subject_id=".(int)$subject_id." and e.exam_id=".(int)$exam_id." and e.student_id=".(int)$student_id." and e.academic_year_id=".(int)$academic_id; $exe=mysql_query($sql); if(mysql_num_rows($exe)) { $row=mysql_fetch_array($exe); $rec['total_marks']=$row['total_marks']; $qry="select marks_secured,status from ced_t_students_marks where subject_id=".(int)$subject_id." and exam_id=".(int)$exam_id." and student_id=".(int)$student_id." and academic_year_id=".(int)$academic_id; $res=mysql_query($qry); if(mysql_num_rows($res)) { $record=mysql_fetch_array($res); $rec['marks_secured']=$record['marks_secured']; if($record['status']=='1') $rec['status']='Pass'; else $rec['status']='Fail'; } else { $rec['marks_secured']='N/A'; $rec['status']='N/A'; } return $rec; } } /////////////////////////////////////////////////////////////////////////////////////////////////////////// function exam_marksof_student($class_id,$section_id,$subject_id,$exam_id) { $sql="SELECT `timetable_id` FROM `ced_t_exam_timetable` WHERE `subject_id`= '".$subject_id."' and `class_id`='".$class_id."' and `section_id` = '".$section_id."' and `exam_id`='".$exam_id."'"; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $error=1; } else { $error=2; } return $error; } function get_totalmarks($subjects,$exam_ids,$student_id) { $subj=implode(",",$subjects); for($i=0;$i<count($exam_ids);$i++) { $sql="SELECT sum(`marks_secured`) as sum FROM `ced_t_students_marks` WHERE `student_id` ='".$student_id."' and `subject_id` in(".$subj.") and `exam_id`='".$exam_ids[$i]."'"; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $row=mysql_fetch_array($result); if($row['sum']>0) { $data[]= $row['sum']; } } } return $data; } function get_exam_name($exam_id) { $sql="SELECT `exam_name` FROM `ced_t_exam_names` WHERE `exam_id`='".$exam_id."'"; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { $row=mysql_fetch_array($result); } return $row['exam_name']; } function delete_student_route($student_route_id,$academic_id) { $sql="DELETE FROM `ced_t_students_routes` WHERE `student_route_id`='".$student_id."' and `academic_year_id`='".$academic_id."'"; $result=mysql_query($sql); if($result) { $error=1; } else { $error=2; } return $error; } function add_students_marks_edit($marks_id,$class_id,$section_id,$school_id,$academic_id,$exam_name_id,$student_id) { $sql="SELECT t.`total_marks` , t.`class_id` , t.`section_id` , t.`pass_marks` , t.`exam_id` , m.`student_marks_id`, m.`marks_secured` , m.`student_id` , m.`subject_id`,m.`status` FROM `ced_t_exam_timetable` t INNER JOIN `ced_t_students_marks` m WHERE t.`class_id` ='".$class_id."' AND t.`section_id` ='".$section_id."' AND t.`academic_year_id` ='".$academic_id."' AND m.`student_id` ='".$student_id."' AND m.`exam_id` ='".$exam_name_id."' AND m.`student_marks_id` ='".$marks_id."' AND m.`subject_id` = t.`subject_id` and t.`exam_id` = m.`exam_id`"; //echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $data['marks_secured']=$row['marks_secured']; $data['pass_marks']=$row['pass_marks']; $data['status']=$row['status']; if($data['status']==1) { $data['status']="P"; } else { $data['status']="F"; } $data['student_marks_id']=$row['student_marks_id']; $data['student_id']=$row['student_id']; $data['exam_id']=$row['exam_id']; $data['student_rollno']=$this->student_rollnumber($row['student_id']); $data['subject_id']=$row['subject_id']; $data['student_name']=$this->student_name($data['student_id']); $data['subject_name']=$this->getsubject_name($row['subject_id'],$school_id,$academic_id); $data['total_marks']=$row['total_marks']; $grade=$this->getStudent_Grade($row['exam_id'],$row['student_id'],$academic_id); if($grade) { $data['grade']=$grade; } else { $data['grade']=""; } $data2[]=$data; } } return $data2; } function update_student_marks_byid($post,$user_id,$academic_id) { $update_date = date('Y-m-d'); $sql="UPDATE `ced_t_students_marks` SET `marks_secured`='".$post['marks']."',`grade`='".$post['grade']."',`status` = '".$post['status']."' , `updated_by`='".$user_id."',`updated_on`= '".$update_date."',academic_year_id='$academic_id' WHERE `student_marks_id`='".$post['marks_id']."' "; $result=mysql_query($sql); if($result) { $check_parents_data = $this->check_parent_data($post['student_id']); if(!empty($check_parents_data)) { $msg['type'] = "exam_res"; $msg['exam_id']=$post['exam_id']; $msg['acadamic_id']=$academic_id; foreach($check_parents_data as $key=>$val) { $registatoin_ids = $val['device_id']; $msg['student_id'] = $val['student_id']; $msg['message'] = "Marks for ".$post['examination_name']." for ".$val['student_firstname']." ".$val['student_lastname']." for AY ".$_SESSION['child']['choosen_year_name']." has been updated"; $noteins="insert into ced_t_notifications set notify_name='".$msg['message']."',student_id=".(int)$val['student_id'].",notify_type='exam_res',read_status=1,general_column1='".$msg['exam_id']."',created_on='".date('Y-m-d')."',general_column2='".$academic_id."'"; mysql_query($noteins); $nstate=$this->getNotestate($val['authenticate_id']); if($registatoin_ids!='' && $nstate=='1') $resultss = $this->send_notice($registatoin_ids,$msg); } } $error=1; } else { $error=2; } return $error; } function addexamination_schedule_all($exam_id,$subject_id,$exam_date,$exam_time,$duration_time,$class_id,$section_id,$academic_id,$user_id,$total_marks,$school_id) { $dateInput = explode('/',$exam_date); $date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $sql12="SELECT * FROM `ced_t_exam_timetable` WHERE `exam_id`='".$exam_id."' and `class_id`='".$class_id."' and `section_id`='".$section_id."' and `subject_id`='".$subject_id."' "; $result12=mysql_query($sql12); if(mysql_num_rows($result12)>0) { $sql="UPDATE `ced_t_exam_timetable` SET `exam_date`='".$date."',`exam_time`='".$exam_time."',`exam_duration`='".$duration_time."', `updated_by`='".$user_id."',`updated_on`=CURDATE(), `total_marks`='".$total_marks."' WHERE `class_id`='".$class_id."' AND `section_id`='".$section_id."' AND `exam_id`='".$exam_id."' AND `subject_id`='".$subject_id."' AND `academic_year_id`='".$academic_id."'"; //$sql="UPDATE `ced_t_exam_timetable` SET `subject_id`='".$subject_id[$i]."', `exam_date`='".$date[$i]."',`exam_time`='".$exam_time[$i]."',`exam_duration`='".$duration_time[$i]."' WHERE `class_id`='".$class_id."' AND `section_id`='".$section_id."' AND `exam_id`='".$exam_id[$i]."' AND `academic_year_id`='".$academic_id."'"; } else { $sql="INSERT INTO `ced_t_exam_timetable`( `subject_id`, `exam_date`, `exam_time`, `exam_duration`, `class_id`, `section_id`, `exam_id`, `academic_year_id`,`total_marks`,`created_by`,`created_on`) VALUES ('".$subject_id."','".$date."','".$exam_time."','".$duration_time."','".$class_id."','".$section_id."','".$exam_id."','".$academic_id."','".$total_marks."','".$user_id."',CURDATE())"; } $result=mysql_query($sql); if($result) { $error=1; } else { $error=2; } return $error; } function subjects_data_all($class_id,$acadamic_id,$school_id) { $sql="SELECT `class_category_id` FROM `ced_t_class` WHERE `class_id`='".$class_id."'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $sql="SELECT `subject_name` ,`subject_id` FROM `ced_t_subjects` where `class_category_id` ='".$row['class_category_id']."' and `school_id`='".$school_id."' and `academic_year_id`='".$acadamic_id."'"; $result=mysql_query($sql); //$count = mysql_num_rows($result); while($row=mysql_fetch_array($result)) { $data_sections[$row['subject_id']] = $row; } return $data_sections; } function sections_data_all($class_id,$academic_id) { $sql="SELECT `section_id` , `section_name` FROM `ced_t_sections` WHERE `class_id` = '".$class_id."' and `academic_year_id`='".$academic_id."' "; //echo $sql; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $data[$row['section_id']]=$row; } return $data; } function check_parent_data($student_ids_data) { $data2=array(); $str = $student_ids_data; $str =rtrim($str,','); $select_parent_qry ="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id inner join ced_t_student_licenses sl on sl.student_id=s.student_id where s.student_id in (".$str.") and sp.account_status=1 and sl.license_status=1"; //"select sp.device_id,sp.student_id,s.student_firstname,s.student_lastname from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.student_id in (".$str.") and sp.account_status=1"; $exe_parent=mysql_query($select_parent_qry); if(mysql_num_rows($exe_parent)) { while($row_parent =mysql_fetch_array($exe_parent)) { $data2[]=$row_parent; } } return $data2; } function getNotestate($authenticate_id) { $sql="select notifications from ced_t_authentication_details where authenticate_id=".(int)$authenticate_id; $exe=mysql_query($sql); if(mysql_num_rows($exe)) { $res=mysql_fetch_array($exe); return $res['notifications']; } } function send_notice($registatoin_ids,$msg) { $registatoin_ids=array($registatoin_ids); $googleapi='AIzaSyDZjnc0dm76JpZpk5mJSw_oOPgfoDSSbR0'; $url = 'https://android.googleapis.com/gcm/send'; $fields = array('registration_ids' => $registatoin_ids,'data' => $msg); $headers = array('Authorization: key='.$googleapi,'Content-Type: application/json'); // Open connection $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } } ?>