403 lines
16 KiB
PHP
Executable File
403 lines
16 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Student_model extends CI_Model
|
|
{
|
|
|
|
/*
|
|
* student details
|
|
*
|
|
* created by kdk
|
|
* */
|
|
|
|
// get student list based on login user
|
|
public function get_student_list($loginUserId, $loginUserBranchId, $loginUserType)
|
|
{
|
|
// echo $loginUserId, $loginUserBranchId, $loginUserType; exit();
|
|
if ($loginUserType == SUPER_ADMIN) {
|
|
// list for super admin
|
|
// if ($loginUserBranchId == 'All') {
|
|
// // for getting all branch details
|
|
// $staffId = $this->selfGetEmpId($loginUserId);
|
|
// $this->db->select('*');
|
|
// $this->db->order_by('CreatedOn', 'DESC');
|
|
// $this->db->from(STAFF);
|
|
// // not for SuperAdmin and Student Role code
|
|
// $this->db->where_not_in('StaffID', $staffId);
|
|
// // $this->db->where('BranchCode', $loginUserBranchId);
|
|
// $empDetails = $this->db->get();
|
|
// $checkArr = $empDetails->result();
|
|
// if (count($checkArr) > 0) {
|
|
// $results['employeeList'] = true;
|
|
// $results['employees_details'] = $empDetails->result();
|
|
// } else {
|
|
// $results['employeeList'] = false;
|
|
// $results['message'] = 'No record found';
|
|
// }
|
|
// } else {
|
|
// $staffId = $this->selfGetEmpId($loginUserId);
|
|
// $this->db->select('*');
|
|
// $this->db->order_by('CreatedOn', 'DESC');
|
|
// $this->db->from(STAFF);
|
|
// // not for SuperAdmin and Student Role code
|
|
// $this->db->where_not_in('StaffID', $staffId);
|
|
// $this->db->where('BranchCode', $loginUserBranchId);
|
|
// $empDetails = $this->db->get();
|
|
// $checkArr = $empDetails->result();
|
|
// if (count($checkArr) > 0) {
|
|
// $results['employeeList'] = true;
|
|
// $results['employees_details'] = $empDetails->result();
|
|
// } else {
|
|
// $results['employeeList'] = false;
|
|
// $results['message'] = 'No record found';
|
|
// }
|
|
|
|
// }
|
|
|
|
} else if ($loginUserType == ADMIN) {
|
|
// list for admin
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
$this->db->where('BranchCode', $loginUserBranchId);
|
|
$stuDetails = $this->db->get();
|
|
$checkArr = $stuDetails->result();
|
|
if (count($checkArr) > 0) {
|
|
$results['studentList'] = true;
|
|
$results['student_details'] = $stuDetails->result();
|
|
} else {
|
|
$results['studentList'] = false;
|
|
}
|
|
} else if ($loginUserType == EMPLOYEE) {
|
|
// list for staff
|
|
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
$this->db->where('BranchCode', $loginUserBranchId);
|
|
$stuDetails = $this->db->get();
|
|
$checkArr = $stuDetails->result();
|
|
if (count($checkArr) > 0) {
|
|
$results['studentList'] = true;
|
|
$results['student_details'] = $stuDetails->result();
|
|
} else {
|
|
$results['studentList'] = false;
|
|
}
|
|
} else {
|
|
|
|
$results['studentList'] = false;
|
|
}
|
|
return $results;
|
|
}
|
|
|
|
public function get_student_course_list($studentId) {
|
|
$this->db->select('t1.*,t2.UniversityName,t3.CourseName,t4.BatchName');
|
|
$this->db->from('' . STUDENTCOURSE . ' as t1');
|
|
$this->db->join('' . UNIVERSITY . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
|
|
$this->db->join('' . COURSE . ' as t3', 't3.CourseID = t1.CourseID', 'LEFT');
|
|
$this->db->join('' . BATCH . ' as t4', 't4.BatchCode = t1.BatchCode', 'LEFT');
|
|
$this->db->where('StudentID', $studentId);
|
|
$courseDetails = $this->db->get();
|
|
$checkArr = $courseDetails->result();
|
|
if (count($checkArr) > 0) {
|
|
$result['stuCourseDetails'] = true;
|
|
$result['course_details'] = $courseDetails->result();
|
|
} else {
|
|
$result['stuCourseDetails'] = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// get student course details
|
|
public function get_student_course($studentcourseId) {
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTCOURSE);
|
|
$this->db->where('ID', $studentcourseId);
|
|
$courseDetails = $this->db->get();
|
|
$checkArr = $courseDetails->result();
|
|
if (count($checkArr) > 0) {
|
|
$result['stuCourseDetails'] = true;
|
|
$result['course_details'] = $courseDetails->result();
|
|
} else {
|
|
$result['stuCourseDetails'] = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// get university list
|
|
public function get_university_list() {
|
|
$this->db->select('*');
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
$this->db->from(UNIVERSITY);
|
|
$this->db->where('IsActive',1);
|
|
$univDetails = $this->db->get();
|
|
$universityDetails = $univDetails->result();
|
|
if (count($universityDetails) > 0) {
|
|
$results['univList'] = true;
|
|
$results['university_details'] = $universityDetails;
|
|
} else {
|
|
$results['univList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
return $results;
|
|
}
|
|
|
|
|
|
//get course for university
|
|
|
|
public function get_courseBatch_list($univId) {
|
|
$this->db->select('C.CourseID, C.CourseName');
|
|
$this->db->from(COURSE.' as C');
|
|
$this->db->where('UniversityID',$univId);
|
|
$this->db->where('IsActive',1);
|
|
$courseDetails = $this->db->get();
|
|
if($courseDetails->result()){
|
|
$this->db->select('B.BatchCode, B.BatchName');
|
|
$this->db->from(BATCH.' as B');
|
|
$this->db->where('UniversityID',$univId);
|
|
$this->db->where('IsActive',1);
|
|
$batchDetails = $this->db->get();
|
|
if( $batchDetails->result()) {
|
|
$result['courseStatus'] = true;
|
|
$result['course_details'] = $courseDetails->result();
|
|
$result['batch_details'] = $batchDetails->result();
|
|
} else {
|
|
$result['courseStatus'] = false;
|
|
$result['message'] = "No records found!";
|
|
}
|
|
}
|
|
else {
|
|
$result['courseStatus'] = false;
|
|
$result['message'] = "No records found!";
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
// check exist
|
|
public function check_exist($data, $checkData)
|
|
{
|
|
if ($checkData == 'studentId') {
|
|
// check for student id
|
|
// $this->db->select('*');
|
|
// $this->db->from(STAFF);
|
|
// $this->db->where('StaffID', $data);
|
|
// if ($this->db->get()->first_row()) {
|
|
// $result['existEmpId'] = true;
|
|
// $result['message'] = "This Employee ID is already exist!";
|
|
// } else {
|
|
// $result['existEmpId'] = false;
|
|
// }
|
|
|
|
} else if ($checkData == 'mobileNumber') {
|
|
// check for mobile number
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('MobileNumber', $data);
|
|
if ($this->db->get()->first_row()) {
|
|
$result['existMobile'] = true;
|
|
$result['message'] = "This Mobile Number is already exist!";
|
|
} else {
|
|
$this->db->select('*');
|
|
$this->db->from(LOGIN);
|
|
$this->db->where('MobileNumber', $data);
|
|
if ($this->db->get()->first_row()) {
|
|
$result['existMobile'] = true;
|
|
$result['message'] = "This Mobile Number is already exist!";
|
|
} else {
|
|
$result['existMobile'] = false;
|
|
}
|
|
}
|
|
|
|
} else if ($checkData == 'emailId') {
|
|
// check for email id
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('EmailID', $data);
|
|
if ($this->db->get()->first_row()) {
|
|
$result['existEmailId'] = true;
|
|
$result['message'] = "This EmailId is already exist!";
|
|
} else {
|
|
$result['existEmailId'] = false;
|
|
}
|
|
} else {
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// add student course
|
|
public function add_student_course( $studID, $Arr) {
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTCOURSE);
|
|
$this->db->where('StudentID', $studID);
|
|
$this->db->where('CourseID', $Arr['CourseID']);
|
|
|
|
if($this->db->get()->first_row()) {
|
|
$result['addStuCourseStatus'] = false;
|
|
$result['message'] = "This Student Already exist for this course";
|
|
} else {
|
|
$this->db->insert(STUDENTCOURSE, $Arr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['addStuCourseStatus'] = true;
|
|
$result['message'] = "Successfully Student Course Details Updated";
|
|
} else {
|
|
$result['addStuCourseStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// add student
|
|
public function add_student($Arr, $courseArr)
|
|
{
|
|
// print_r($Arr);
|
|
// print_r($courseArr);exit();
|
|
$this->db->insert(STUDENTS, $Arr);
|
|
$insert_id = $this->db->insert_id('StudentID');
|
|
$courseArr['StudentID'] = $insert_id;
|
|
if ($this->db->affected_rows() == '1') {
|
|
$this->db->insert(STUDENTCOURSE, $courseArr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$loginArr['StaffID'] = $courseArr['StudentID'];
|
|
$loginArr['ListCode'] = STUDENT;
|
|
$loginArr['MobileNumber'] = $Arr['MobileNumber'];
|
|
$loginArr['EmailId'] = $Arr['EmailID'];
|
|
$loginArr['IsActive'] = $Arr['IsActive'];
|
|
$loginArr['CreatedBy'] = $Arr['CreatedBy'];
|
|
$loginArr['CreatedOn'] = $Arr['CreatedOn'];
|
|
$loginArr['Password'] = ENCR_PASSWORD;
|
|
$this->db->insert(LOGIN, $loginArr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['addStudentStatus'] = true;
|
|
$result['message'] = "Successfully student details added";
|
|
} else {
|
|
$result['addStudentStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
} else {
|
|
$result['addStudentStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
} else {
|
|
$result['addStudentStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// check existing data while update
|
|
public function check_update_exist($exceptId, $datas, $checkFor)
|
|
{
|
|
if ($checkFor == 'mobileNumber') {
|
|
// check update for mobile number
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('MobileNumber', $datas);
|
|
$this->db->where_not_in('StudentID', $exceptId);
|
|
if ($this->db->get()->first_row()) {
|
|
$result['existMobile'] = true;
|
|
$this->db->select('MobileNumber');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('StudentID', $exceptId);
|
|
$result['resetValue'] = $this->db->get()->first_row();
|
|
$result['message'] = "This Mobile Number is already exist!";
|
|
} else {
|
|
// check login
|
|
$this->db->select('*');
|
|
$this->db->from(LOGIN);
|
|
$this->db->where('MobileNumber', $datas);
|
|
$this->db->where_not_in('StaffID', $exceptId);
|
|
if($this->db->get()->first_row()) {
|
|
$result['existMobile'] = true;
|
|
$this->db->select('MobileNumber');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('StudentID', $exceptId);
|
|
$result['resetValue'] = $this->db->get()->first_row();
|
|
$result['message'] = "This Mobile Number is already exist!";
|
|
} else {
|
|
$result['existMobile'] = false;
|
|
}
|
|
}
|
|
|
|
} else if ($checkFor == 'emailId') {
|
|
// check update for email
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('EmailID', $datas);
|
|
$this->db->where_not_in('StudentID', $exceptId);
|
|
if ($this->db->get()->first_row()) {
|
|
$result['existEmailId'] = true;
|
|
$this->db->select('EmailID');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('StudentID', $exceptId);
|
|
$result['resetValue'] = $this->db->get()->first_row();
|
|
$result['message'] = "This EmailId is already exist!";
|
|
} else {
|
|
$result['existEmailId'] = false;
|
|
}
|
|
} else {
|
|
}
|
|
return $result;
|
|
}
|
|
// update student personal details
|
|
public function update_student($empArr, $updateFor)
|
|
{
|
|
// print_r($empArr);
|
|
// print_r($updateFor);
|
|
// exit();
|
|
$this->db->where('StudentID', $updateFor);
|
|
$this->db->update(STUDENTS, $empArr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$mobile = $empArr['MobileNumber'];
|
|
$email = $empArr['EmailID'];
|
|
$active = $empArr['IsActive'];
|
|
$updatedBy = $empArr['UpdatedBy'];
|
|
$updatedOn = $empArr['UpdatedOn'];
|
|
$sql = "UPDATE ".LOGIN." SET MobileNumber='$mobile', EmailId='$email', IsActive='$active', UpdatedBy='$updatedBy', UpdatedOn='$updatedOn' WHERE StaffID='$updateFor'";
|
|
if($this->db->query($sql) == '1'){
|
|
$result['updateStuStatus'] = true;
|
|
$result['message'] = "Successfully student details Updated";
|
|
} else {
|
|
$result['updateStuStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
} else {
|
|
$result['updateStuStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
public function update_student_course($reqArr, $id) {
|
|
// print_r($id);
|
|
// print_r($reqArr);
|
|
// exit();
|
|
$this->db->select('*');
|
|
$this->db->from(STUDENTCOURSE);
|
|
$this->db->where('StudentID', $reqArr['StudentID']);
|
|
$this->db->where('CourseID', $reqArr['CourseID']);
|
|
$this->db->where_not_in('ID', $id);
|
|
if($this->db->get()->first_row()) {
|
|
$result['updateStuCourseStatus'] = false;
|
|
$result['message'] = "This Student Already exist for this course";
|
|
} else {
|
|
$this->db->where('ID', $id);
|
|
$this->db->update(STUDENTCOURSE, $reqArr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['updateStuCourseStatus'] = true;
|
|
$result['message'] = "Successfully Student Course Details Updated";
|
|
} else {
|
|
$result['updateStuCourseStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
} |