db->select('t1.BranchCode,t1.BranchName'); $this->db->from('' . BRANCH . ' as t1'); // $this->db->where('t1.IsActive', 1); $branchDetails = $this->db->get(); $checkArr = $branchDetails->result(); if (count($checkArr) > 0) { $result['branDetailstatus'] = true; $result['branch_details'] = $branchDetails->result(); } else { $result['branDetailstatus'] = false; } return $result; } // check the branch active status for student add public function getBranchActiveStatusforStuAdd($branchId) { $this->db->select('t1.IsActive'); $this->db->from('' . BRANCH . ' as t1'); $this->db->where('BranchCode', $branchId); $statusDetails = $this->db->get()->first_row(); // echo $statusDetails->IsActive;exit(); $result['branch_active_status'] = $statusDetails->IsActive; return $result; // if (count($checkArr) > 0) { // $result['branDetailstatus'] = true; // $result['branch_details'] = $branchDetails->result(); // } else { // $result['branDetailstatus'] = false; // } // return $result; } // get student list based on login user public function get_student_list($loginUserId, $loginUserBranchId, $loginUserType, $getSearchData) { // print_r($getSearchData);exit(); // echo $loginUserId, $loginUserBranchId, $loginUserType; exit(); if ($loginUserType == SUPER_ADMIN) { // list for super admin based on branch if ($getSearchData["University"] === '' && $getSearchData["Course"] === '' && $getSearchData["Status"] === '') { $this->db->select('*'); $this->db->from('' . STUDENTS . ' as t1'); // $this->db->order_by('CreatedOn', 'DESC'); // $this->db->where('BranchCode', $loginUserBranchId); $this->db->join('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT'); $this->db->where('t2.BranchID', $loginUserBranchId); $this->db->group_by('t2.StudentID'); $this->db->order_by('t2.CreatedOn', 'DESC'); $stuDetails = $this->db->get(); $checkArr = $stuDetails->result(); if (count($checkArr) > 0) { $results['studentList'] = true; $results['student_details'] = $stuDetails->result(); } else { $results['studentList'] = false; } } else { // print_r($getSearchData);exit(); // $this->db->select('t1.*'); // // $this->db->from(STUDENTS); // $this->db->from('' . STUDENTS . ' as t1'); // $this->db->order_by('t1.CreatedOn', 'DESC'); // $this->db->where('t1.BranchCode', $loginUserBranchId); // $this->db->from('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT'); // $this->db->where('t2.UniversityID', $getSearchData["University"]); // $this->db->where('t2.CourseID', $getSearchData["Course"]); $University = $getSearchData['University']; $Course = $getSearchData['Course']; // $Batch = $getSearchData['Batch']; $Batch = ''; $StuStatus = $getSearchData['Status']; if ($StuStatus == '') { if ($University != '' && $Course == '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } else if ($University != '' && $Course != '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.CourseID = '$Course' AND SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } } else { if ($University != '' && $Course == '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' AND S.IsActive = '$StuStatus' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } else if ($University != '' && $Course != '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.CourseID = '$Course' AND SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' AND S.IsActive = '$StuStatus' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } } $stuDetails = $this->db->query($subQuery); // $stuDetails = $this->db->get(); $checkArr = $stuDetails->result(); if (count($checkArr) > 0) { $results['studentList'] = true; $results['student_details'] = $stuDetails->result(); } else { $results['studentList'] = false; } } // 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 if ($getSearchData["University"] === '' && $getSearchData["Course"] === '' && $getSearchData["Status"] === '') { // print_r($getSearchData);exit(); $this->db->select('*'); $this->db->from('' . STUDENTS . ' as t1'); // $this->db->where('BranchCode', $loginUserBranchId); // $this->db->group_by('user_id'); $this->db->join('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT'); $this->db->where('t2.BranchID', $loginUserBranchId); $this->db->group_by('t2.StudentID'); $this->db->order_by('t2.CreatedOn', 'DESC'); $stuDetails = $this->db->get(); $checkArr = $stuDetails->result(); if (count($checkArr) > 0) { $results['studentList'] = true; $results['student_details'] = $stuDetails->result(); } else { $results['studentList'] = false; } } else { $University = $getSearchData['University']; $Course = $getSearchData['Course']; // $Batch = $getSearchData['Batch']; $Batch = ''; $StuStatus = $getSearchData['Status']; if ($StuStatus == '') { if ($University != '' && $Course == '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } else if ($University != '' && $Course != '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.CourseID = '$Course' AND SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } } else { if ($University != '' && $Course == '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' AND S.IsActive = '$StuStatus' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } else if ($University != '' && $Course != '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.CourseID = '$Course' AND SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' AND S.IsActive = '$StuStatus' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } } $stuDetails = $this->db->query($subQuery); // $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 // list for admin if ($getSearchData["University"] === '' && $getSearchData["Course"] === '' && $getSearchData["Status"] === '') { // print_r($getSearchData);exit(); $this->db->select('t1.*'); $this->db->from('' . STUDENTS . ' as t1'); $this->db->join('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT'); $this->db->where('t2.BranchID', $loginUserBranchId); $this->db->group_by('t2.StudentID'); // $this->db->from(STUDENTS); $this->db->order_by('t2.CreatedOn', 'DESC'); $stuDetails = $this->db->get(); $checkArr = $stuDetails->result(); if (count($checkArr) > 0) { $results['studentList'] = true; $results['student_details'] = $stuDetails->result(); } else { $results['studentList'] = false; } } else { // print_r($getSearchData);exit(); // $this->db->select('t1.*'); // // $this->db->from(STUDENTS); // $this->db->from('' . STUDENTS . ' as t1'); // $this->db->order_by('t1.CreatedOn', 'DESC'); // $this->db->where('t1.BranchCode', $loginUserBranchId); // $this->db->from('' . STUDENTCOURSE . ' as t2', 't2.StudentID = t1.StudentID', 'LEFT'); // $this->db->where('t2.UniversityID', $getSearchData["University"]); // $this->db->where('t2.CourseID', $getSearchData["Course"]); $University = $getSearchData['University']; $Course = $getSearchData['Course']; // $Batch = $getSearchData['Batch']; $Batch = ''; $StuStatus = $getSearchData['Status']; if ($StuStatus == '') { if ($University != '' && $Course == '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } else if ($University != '' && $Course != '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.CourseID = '$Course' AND SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } // ### query branch code changed from student branch code to student course branch code // AND S.BranchCode = '$loginUserBranchId' -> SC.BranchCode = '$loginUserBranchId' // (SC.UniversityID = '$University' // OR (SC.CourseID = '$Course' AND SC.UniversityID = '$University')) } else { if ($University != '' && $Course == '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' AND S.IsActive = '$StuStatus' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } else if ($University != '' && $Course != '') { $subQuery = "SELECT S.* FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON SC.CourseID = C.CourseID WHERE SC.CourseID = '$Course' AND SC.UniversityID = '$University' AND SC.BranchID = '$loginUserBranchId' AND S.IsActive = '$StuStatus' GROUP BY SC.StudentID ORDER BY S.CreatedOn"; } // ### query branch code changed from student branch code to student course branch code // AND S.BranchCode = '$loginUserBranchId' -> SC.BranchCode = '$loginUserBranchId' } $stuDetails = $this->db->query($subQuery); // $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; } // get a student cource list public function get_student_course_list($studentId, $req) { // echo $req['localBranchID'];exit(); $this->db->select('t1.*,t2.UniversityName,t3.CourseName,t3.CourseCode,t3.Specilization1,t3.Specilization2,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('t1.BranchID', $req['localBranchID']); $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, batch for university public function get_courseBatch_list($univId) { $this->db->select('C.CourseID, C.CourseName,C.Specilization1,C.Specilization2, C.CourseCode'); $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; } // Get exist student details public function get_exist_stu_details($data, $reqArr) { // echo $data;exit(); $this->db->select('t0.*'); $this->db->from('' . STUDENTS . ' as t0'); $this->db->where('t0.StudentID', $data); $personalDetails = $this->db->get()->result(); $this->db->select('t1.*,t2.UniversityName,t3.CourseName,t3.Specilization1,t3.Specilization2,t4.BatchName, t5.BranchName'); // $this->db->from('' . STUDENTS . ' as t0'); $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->join('' . BRANCH . ' as t5', 't5.BranchCode = t1.BranchID', 'LEFT'); $this->db->where('t1.StudentID', $data); // $this->db->group_by('t1.StudentID'); $courseDetails = $this->db->get()->result(); $result['personalDetails'] = $personalDetails; $result['courseDetails'] = $courseDetails; $result['existingStudentDetailsStatus'] = true; 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); $details = $this->db->get()->result(); // echo count($details);exit(); if (count($details) > 0) { // print_r($details);exit(); // echo $details[0]->StudentID;exit(); $datas['studentId'] = $details[0]->StudentID; $datas['type'] = 'R001'; $result['details'] = $datas; $result['existMobile'] = true; $result['message'] = "This Mobile Number is already exist!"; } else { $this->db->select('*'); $this->db->from(LOGIN); $this->db->where('MobileNumber', $data); $details1 = $this->db->get()->result(); if ($details1 > 0) { $datas['studentId'] = $details1[0]->StaffID; $datas['type'] = $details1[0]->ListCode; $result['details'] = $datas; $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) { if ($this->getBranchActiveStatusforStuAdd($Arr['BranchID']) ['branch_active_status'] === '1') { $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"; } } } else { $result['addStuCourseStatus'] = false; $result['message'] = "New Cource Cannot able to create for In-Active Branch"; } return $result; } // add student public function add_student($Arr, $courseArr, $imagename, $imageSource, $size) { // echo $this->getBranchActiveStatusforStuAdd($courseArr['BranchID'])['branch_active_status'];exit(); if ($this->getBranchActiveStatusforStuAdd($courseArr['BranchID']) ['branch_active_status'] === '1') { // echo 'in';exit(); if ($imageSource == '') { // add employee without image $imageNameDb = 'default.jpeg'; $Arr['ProfilePicPath'] = "student/" . $imageNameDb; // print_r($Arr); // print_r($courseArr);exit(); $this->db->select('*'); $this->db->from(STUDENTS); $this->db->where('MobileNumber', $Arr['MobileNumber']); if ($this->db->get()->first_row()) { $result['addStudentStatus'] = false; $result['message'] = "This Student Already exist"; } else { $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"; } } } else { $target = "../images/student/"; $getUploadStatus = $this->upload_image($imageSource, $size, $target); $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg'; $Arr['ProfilePicPath'] = "student/" . $imageNameDb; $this->db->select('*'); $this->db->from(STUDENTS); $this->db->where('MobileNumber', $Arr['MobileNumber']); if ($this->db->get()->first_row()) { $result['addStudentStatus'] = false; $result['message'] = "This Student Already exist"; } else { $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"; } } } } else { $result['addStudentStatus'] = false; $result['message'] = "New Student cannot able to create for In-Active Branch"; } 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; } // get the student entrollment doc details public function getStudent_doc_details($stuId) { $this->db->select('*'); $this->db->order_by('CreatedOn', 'DESC'); $this->db->from('T_StudentDocumentsDetails'); $this->db->where('StudentID', $stuId); $getDocDetails = $this->db->get(); $documentDetails = $getDocDetails->result(); if (count($documentDetails) > 0) { $results['docListStatus'] = true; $results['student_doc_details'] = $documentDetails; } else { $results['docListStatus'] = false; $results['message'] = 'No record found'; } return $results; } public function deleteStu_doc_details($stuId, $docId) { $sql1 = "SELECT * FROM T_StudentDocumentsDetails WHERE StudentID = '" . $stuId . "' AND ID = '" . $docId . "'"; $resultSql1 = $this->db->query($sql1)->result(); if(count($resultSql1) > 0){ // print_r($resultSql1); // echo $resultSql1[0]->DocumentStorePath;exit(); $sql = "DELETE FROM T_StudentDocumentsDetails WHERE StudentID = '" . $stuId . "' AND ID = '" . $docId . "'"; if ($this->db->query($sql)) { try{ if(!file_exists('../images/' . $resultSql1[0]->DocumentStorePath)) { throw new Exception("File Not Found."); }else { unlink('../images/' . $resultSql1[0]->DocumentStorePath); } } catch(Exception $e){ // echo "Error :"; } finally { $results['message'] = 'Deleted Successfully.'; $results['deleteStatus'] = true; } } else { $results['deleteStatus'] = false; $results['message'] = 'Something went wrong.please try again'; } }else{ $results['deleteStatus'] = false; $results['message'] = 'Something went wrong.please try again'; } return $results; } // add student entroll doc details public function student_entroll_doc_add($req, $doc_status) { // if( $doc_status == "true") { $target = "../images/documents/"; $getUploadStatus = $this->upload_doc_student($req['doc_source'], $req['doc_name'], $req['doc_size'], $target, $req['student_id']); if ($imageNameDb = $getUploadStatus['status'] == true) { $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg'; // echo $imageNameDb;exit(); $strPath = "documents/" . $imageNameDb; $stuId = $req['student_id']; $docTypeName = $req['document_type_name']; $docStatus = $req['document_status']; $docComments = $req['document_comments']; $docCreatedBy = $req['CreatedBy']; $docCreatadOn = $req['CreatedOn']; // echo $docCreatadOn;exit(); // ".STAFF_BRANCH." $sql1 = "INSERT INTO T_StudentDocumentsDetails (StudentID, DocumentName, Status, DocumentStorePath, Comments, CreatedBy, CreatedOn) VALUES ('$stuId', '$docTypeName', '$docStatus', '$strPath', '$docComments', '$docCreatedBy', '$docCreatadOn')"; // update branch to staff_branch table if ($this->db->query($sql1) == '1') { $result['stuDocUpdateStatus'] = true; $result['message'] = "Successfully Student document details updated"; } else { $result['stuDocUpdateStatus'] = false; $result['message'] = "Something went wrong.please try again"; } } else { $result['stuDocUpdateStatus'] = false; $result['message'] = "Something went wrong.please try again"; } return $result; } // student document upload target path public function upload_doc_student($imageSource, $doc_name, $size, $target, $stu_id) { $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') , 0, 12); $new_regNo = "Dri_" . $key2 . "_" . $stu_id . "_" . $doc_name; $targetPlace = $target . $new_regNo; // echo $targetPlace;exit(); if (!move_uploaded_file($imageSource, $targetPlace)) { return $result['status'] = false; } else { $result['status'] = true; $result['imageName'] = $new_regNo; return $result; } } // update student personal details public function update_student($empArr, $updateFor, $imagename, $imageSource, $size) { if ($imageSource == '') { // print_r($empArr); // print_r($updateFor); // exit(); $this->db->select('*'); $this->db->from(STUDENTS); $this->db->where('MobileNumber', $empArr['MobileNumber']); $this->db->where_not_in('StudentID', $updateFor); if ($this->db->get()->first_row()) { $result['updateStuStatus'] = false; $result['message'] = "This Mobile Number Already Exist"; } else { $this->db->select('*'); $this->db->from(LOGIN); $this->db->where('MobileNumber', $empArr['MobileNumber']); $this->db->where_not_in('StaffID', $updateFor); if ($this->db->get()->first_row()) { $result['updateStuStatus'] = false; $result['message'] = "This Mobile Number Already Exist"; } else { $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"; } } } } else { $this->db->select('*'); $this->db->from(STUDENTS); $this->db->where('MobileNumber', $empArr['MobileNumber']); $this->db->where_not_in('StudentID', $updateFor); if ($this->db->get()->first_row()) { $result['updateStuStatus'] = false; $result['message'] = "This Mobile Number Already Exist"; } else { $this->db->select('*'); $this->db->from(LOGIN); $this->db->where('MobileNumber', $empArr['MobileNumber']); $this->db->where_not_in('StaffID', $updateFor); if ($this->db->get()->first_row()) { $result['updateStuStatus'] = false; $result['message'] = "This Mobile Number Already Exist"; } else { $target = "../images/student/"; $getUploadStatus = $this->upload_image($imageSource, $size, $target); $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg'; $empArr['ProfilePicPath'] = "student/" . $imageNameDb; $this->db->select('ProfilePicPath'); $this->db->from(STUDENTS); $this->db->where('StudentID', $updateFor); $roleDetails = $this->db->get()->first_row(); // echo $roleDetails->ProfilePicPath; // exit(); if ($roleDetails->ProfilePicPath != '' && $roleDetails->ProfilePicPath != 'student/default.jpeg') { unlink('../images/' . $roleDetails->ProfilePicPath); } else { } $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; } // Update Student Course Details 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; } // image upload in taget path public function upload_image($imageSource, $size, $target) { $key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') , 0, 12); $new_regNo = "Dri_" . $key2 . "." . 'jpeg'; $targetPlace = $target . $new_regNo; // echo $targetPlace;exit(); if (!move_uploaded_file($imageSource, $targetPlace)) { return $result['status'] = false; } else { $result['status'] = true; $result['imageName'] = $new_regNo; return $result; } } }