diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index dc680e82..9febde63 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -79,6 +79,7 @@ $route['getEmpBranchDetails'] = 'Employee_Controller/getEmpBranchDetails'; $route['updateEmpBranchDetail'] = 'Employee_Controller/updateEmpBranchDetail'; $route['updateEmpImgExistDetail'] = 'Employee_Controller/updateEmployeeImage'; $route['insertEmployeeImage'] = 'Employee_Controller/addEmployeeImage'; +$route['employeeGetProf'] = 'Employee_Controller/employeeGetProf'; // call tracking $route['getTrackingLeadDetails'] = 'Call_Tracking_Controller/getTrackingLeadDetails'; @@ -115,6 +116,8 @@ $route['getStudentCourseList'] = 'Student_Controller/getStudentCourseList'; $route['getStudentCourseDetails'] = 'Student_Controller/getStudentCourseDetails'; $route['updateStudentCourseDetail'] = 'Student_Controller/updateStudentCourseDetail'; $route['insertStudentCourse'] = 'Student_Controller/insertStudentCourse'; +$route['insertStudentImg'] = 'Student_Controller/insertStudentImg'; +$route['updateStudentImgDetails'] = 'Student_Controller/updateStudentImgDetails'; //batch $route['addBatchDetails'] = 'Batch_Controller/addBatchDetails'; diff --git a/Apollo/api/application/controllers/Employee_Controller.php b/Apollo/api/application/controllers/Employee_Controller.php index 94d59a71..c96b8bf6 100755 --- a/Apollo/api/application/controllers/Employee_Controller.php +++ b/Apollo/api/application/controllers/Employee_Controller.php @@ -45,6 +45,26 @@ class Employee_Controller extends REST_Controller { $this->load->model('Employee_model', 'employee_model'); } + // get login employee profile details + public function employeeGetProf_post() { + $empLoginID = $this->post('employeeLoginID'); + $employeeDetails = $this->employee_model->get_emp_prof_detail( $empLoginID );// Check if the employee exist + if ($employeeDetails) + { + $employeeDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($employeeDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + //This method used to get employee Details public function employee_post() { @@ -151,7 +171,7 @@ class Employee_Controller extends REST_Controller { } } - // add employee with image + // add employee without image public function addEmployee_post() { $data = $this->post('data'); $createdBy = $this->post('createdBy'); @@ -207,6 +227,7 @@ class Employee_Controller extends REST_Controller { $imagename = $_FILES['idProof']['name']; $size = $_FILES['idProof']['size']; + $imageSource = $_FILES['idProof']['tmp_name']; // echo $size;exit(); $data= $this->post('data'); diff --git a/Apollo/api/application/controllers/Student_Controller.php b/Apollo/api/application/controllers/Student_Controller.php index d0dfda86..1843e41f 100755 --- a/Apollo/api/application/controllers/Student_Controller.php +++ b/Apollo/api/application/controllers/Student_Controller.php @@ -177,11 +177,78 @@ class Student_Controller extends REST_Controller { } } + public function updateStudentImgDetails_post() { + + $imagename = $_FILES['idStuUpProof']['name']; + $size = $_FILES['idStuUpProof']['size']; + $imageSource = $_FILES['idStuUpProof']['tmp_name']; + + $temp= $this->post('data'); + $data = json_decode($temp, true); + + $updatedBy = $this->post('updatedBy'); + $updateStudent = $data['StudentID']; + + $req['MobileNumber'] = $data['MobileNumber']; + $req['Firstname'] = $data['Firstname']; + $req['Lastname'] = $data['Lastname']; + $req['Fathername'] = $data['Fathername']; + $req['EmailID'] = $data['EmailID']; + $req['MotherName'] = $data['MotherName']; + + $req['AlternateNumber'] = $data['AlternateNumber']; + $req['Gender'] = $data['Gender']; + $req['DOB'] = $data['DOB']; + $req['PresentAddress'] = $data['PresentAddress']; + $req['PermanentAddress'] = $data['PermanentAddress']; + $req['AadharNumber'] = $data['AadharNumber']; + $req['OtherID'] = $data['OtherID']; + $req['OtherIDDetails'] = $data['OtherIDDetails']; + $req['Qualification'] = $data['Qualification']; + + $req['PreQualification'] = $data['PreQualification']; + $req['Caste'] = $data['Caste']; + $req['Category'] = $data['Category']; + $req['Religion'] = $data['Religion']; + $req['Nationality'] = $data['Nationality']; + $req['Occupation'] = $data['Occupation']; + $req['Designation'] = $data['Designation']; + $req['Companyname'] = $data['Companyname']; + $req['ReferredBy'] = $data['ReferredBy']; + $req['ReferersMobileNumber'] = $data['ReferersMobileNumber']; + $req['ProfilePicPath'] = $data['ProfilePicPath']; + + $req['IsActive'] = $data['IsActive']; + + $req['UpdatedBy'] = $updatedBy; + $date = date('Y-m-d H:i:s'); + $req['UpdatedOn'] = $date; + $studentUpdate = $this->student_model->update_student( $req, $updateStudent, $imagename, $imageSource, $size );// Check if the employee exist + if ($studentUpdate) + { + $studentUpdate['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($studentUpdate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + } public function updateStudentExistDetail_post(){ $data = $this->post('data'); $updatedBy = $this->post('updatedBy'); $updateStudent = $data['StudentID']; + $imagename = ''; + $size = ''; + $imageSource = ''; + $req['MobileNumber'] = $data['MobileNumber']; $req['Firstname'] = $data['Firstname']; $req['Lastname'] = $data['Lastname']; @@ -209,13 +276,14 @@ class Student_Controller extends REST_Controller { $req['Companyname'] = $data['Companyname']; $req['ReferredBy'] = $data['ReferredBy']; $req['ReferersMobileNumber'] = $data['ReferersMobileNumber']; + $req['ProfilePicPath'] = $data['ProfilePicPath']; $req['IsActive'] = $data['IsActive']; $req['UpdatedBy'] = $updatedBy; $date = date('Y-m-d H:i:s'); $req['UpdatedOn'] = $date; - $studentUpdate = $this->student_model->update_student( $req, $updateStudent );// Check if the employee exist + $studentUpdate = $this->student_model->update_student( $req, $updateStudent, $imagename, $imageSource, $size );// Check if the employee exist if ($studentUpdate) { $studentUpdate['status'] = REST_Controller::HTTP_OK; @@ -308,68 +376,144 @@ class Student_Controller extends REST_Controller { } } + public function insertStudentImg_post() { + // print_r($this->post('idProof'));exit(); + $imagename = $_FILES['idStuProof']['name']; + $size = $_FILES['idStuProof']['size']; + $imageSource = $_FILES['idStuProof']['tmp_name']; + // echo $size;exit(); + $temp = $this->post('data'); + $tempBranch = $this->post('coursedata'); + $data = json_decode($temp, true); + $coursedata = json_decode($tempBranch, true); + + $createdBy = $this->post('createdBy'); + $createdBranch = $this->post('loginBranch'); + + $req['Firstname'] = $data['firstname']; + $req['Lastname'] = $data['lastname']; + $req['Fathername'] = $data['fathername']; + $req['EmailID'] = $data['emailId']; + $req['MotherName'] = $data['mothername']; + $req['MobileNumber'] = $data['primaryPhone']; + $req['AlternateNumber'] = $data['secondaryPhone']; + $req['Gender'] = $data['gender']; + $req['DOB'] = $data['dateofbirth']; + $req['PresentAddress'] = $data['address2']; + $req['PermanentAddress'] = $data['address1']; + $req['AadharNumber'] = $data['aadharNumber']; + $req['OtherID'] = $data['otherId']; + $req['OtherIDDetails'] = $data['otherIdDetails']; + $req['Caste'] = $data['caste']; + $req['Category'] = $data['category']; + $req['Religion'] = $data['religion']; + $req['Nationality'] = $data['nationality']; + $req['Occupation'] = $data['occupation']; + $req['Designation'] = $data['designation']; + $req['Companyname'] = $data['companyname']; + $req['ReferredBy'] = $data['referredby']; + $req['ReferersMobileNumber'] = $data['referredmobilenumber']; + $req['PreQualification'] = $data['prequalification']; + $req['IsActive'] = $data['switchsetting']; + $req['BranchCode'] = $createdBranch; + + $req['CreatedBy'] = $createdBy; + $date = date('Y-m-d H:i:s'); + $req['CreatedOn'] = $date; + + $reqCourse['UniversityID'] = $coursedata['university']; + $reqCourse['CourseID'] = $coursedata['course']; + $reqCourse['BatchCode'] = $coursedata['batch']; + $reqCourse['DOJ'] = $coursedata['dateofjoining']; + $reqCourse['BranchID'] = $createdBranch; + $reqCourse['IsActive'] = $data['switchsetting']; + $reqCourse['EnrollmentID'] = $coursedata['enrollmentid']; + $reqCourse['CreatedBy'] = $createdBy; + $date = date('Y-m-d H:i:s'); + $reqCourse['CreatedOn'] = $date; + + $studentAdd = $this->student_model->add_student( $req , $reqCourse, $imagename, $imageSource, $size);// Check if the employee exist + if ($studentAdd) { + $studentAdd['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($studentAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } else { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + // add student public function addStudent_post() { - $data = $this->post('data'); - $coursedata = $this->post('coursedata'); - $createdBy = $this->post('createdBy'); - $createdBranch = $this->post('loginBranch'); - $req['Firstname'] = $data['firstname']; - $req['Lastname'] = $data['lastname']; - $req['Fathername'] = $data['fathername']; - $req['EmailID'] = $data['emailId']; - $req['MotherName'] = $data['mothername']; - $req['MobileNumber'] = $data['primaryPhone']; - $req['AlternateNumber'] = $data['secondaryPhone']; - $req['Gender'] = $data['gender']; - $req['DOB'] = $data['dateofbirth']; - $req['PresentAddress'] = $data['address2']; - $req['PermanentAddress'] = $data['address1']; - $req['AadharNumber'] = $data['aadharNumber']; - $req['OtherID'] = $data['otherId']; - $req['OtherIDDetails'] = $data['otherIdDetails']; - $req['Caste'] = $data['caste']; - $req['Category'] = $data['category']; - $req['Religion'] = $data['religion']; - $req['Nationality'] = $data['nationality']; - $req['Occupation'] = $data['occupation']; - $req['Designation'] = $data['designation']; - $req['Companyname'] = $data['companyname']; - $req['ReferredBy'] = $data['referredby']; - $req['ReferersMobileNumber'] = $data['referredmobilenumber']; - $req['PreQualification'] = $data['prequalification']; - $req['IsActive'] = $data['switchsetting']; - $req['BranchCode'] = $createdBranch; - - $req['CreatedBy'] = $createdBy; - $date = date('Y-m-d H:i:s'); - $req['CreatedOn'] = $date; - - $reqCourse['UniversityID'] = $coursedata['university']; - $reqCourse['CourseID'] = $coursedata['course']; - $reqCourse['BatchCode'] = $coursedata['batch']; - $reqCourse['DOJ'] = $coursedata['dateofjoining']; - $reqCourse['BranchID'] = $createdBranch; - $reqCourse['IsActive'] = $data['switchsetting']; - $reqCourse['EnrollmentID'] = $coursedata['enrollmentid']; - $reqCourse['CreatedBy'] = $createdBy; - $date = date('Y-m-d H:i:s'); - $reqCourse['CreatedOn'] = $date; - - $studentAdd = $this->student_model->add_student( $req , $reqCourse);// Check if the employee exist - if ($studentAdd) { - $studentAdd['status'] = REST_Controller::HTTP_OK; - // Set the response and exit - $this->response($studentAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code - } else { - // Set the response and exit - $this->response([ - 'message' => 'No users were found', - 'status' => REST_Controller::HTTP_NOT_FOUND - ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code - } + $imagename = ''; + $size = ''; + $imageSource = ''; + + $data = $this->post('data'); + $coursedata = $this->post('coursedata'); + $createdBy = $this->post('createdBy'); + $createdBranch = $this->post('loginBranch'); + + $req['Firstname'] = $data['firstname']; + $req['Lastname'] = $data['lastname']; + $req['Fathername'] = $data['fathername']; + $req['EmailID'] = $data['emailId']; + $req['MotherName'] = $data['mothername']; + $req['MobileNumber'] = $data['primaryPhone']; + $req['AlternateNumber'] = $data['secondaryPhone']; + $req['Gender'] = $data['gender']; + $req['DOB'] = $data['dateofbirth']; + $req['PresentAddress'] = $data['address2']; + $req['PermanentAddress'] = $data['address1']; + $req['AadharNumber'] = $data['aadharNumber']; + $req['OtherID'] = $data['otherId']; + $req['OtherIDDetails'] = $data['otherIdDetails']; + $req['Caste'] = $data['caste']; + $req['Category'] = $data['category']; + $req['Religion'] = $data['religion']; + $req['Nationality'] = $data['nationality']; + $req['Occupation'] = $data['occupation']; + $req['Designation'] = $data['designation']; + $req['Companyname'] = $data['companyname']; + $req['ReferredBy'] = $data['referredby']; + $req['ReferersMobileNumber'] = $data['referredmobilenumber']; + $req['PreQualification'] = $data['prequalification']; + $req['IsActive'] = $data['switchsetting']; + $req['BranchCode'] = $createdBranch; + + $req['CreatedBy'] = $createdBy; + $date = date('Y-m-d H:i:s'); + $req['CreatedOn'] = $date; + + $reqCourse['UniversityID'] = $coursedata['university']; + $reqCourse['CourseID'] = $coursedata['course']; + $reqCourse['BatchCode'] = $coursedata['batch']; + $reqCourse['DOJ'] = $coursedata['dateofjoining']; + $reqCourse['BranchID'] = $createdBranch; + $reqCourse['IsActive'] = $data['switchsetting']; + $reqCourse['EnrollmentID'] = $coursedata['enrollmentid']; + $reqCourse['CreatedBy'] = $createdBy; + $date = date('Y-m-d H:i:s'); + $reqCourse['CreatedOn'] = $date; + + + $studentAdd = $this->student_model->add_student( $req , $reqCourse, $imagename, $imageSource, $size);// Check if the employee exist + if ($studentAdd) { + $studentAdd['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($studentAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } else { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } } diff --git a/Apollo/api/application/models/Employee_model.php b/Apollo/api/application/models/Employee_model.php index 5952b1be..3502cf9b 100755 --- a/Apollo/api/application/models/Employee_model.php +++ b/Apollo/api/application/models/Employee_model.php @@ -17,6 +17,68 @@ class Employee_model extends CI_Model /* * get Employee Details, Employee Branch Details */ + + // get login employee profile details + public function get_emp_prof_detail($empLoginID = null) { + $this->db->select('StaffID'); + $this->db->from(LOGIN); + $this->db->where('ID', $empLoginID); + $loginEmpDetail = $this->db->get()->first_row(); + if ($loginEmpDetail) { + $EmpId = $loginEmpDetail->StaffID; + $this->db->select('t1.*'); + $this->db->from('' . STAFF . ' as t1'); + $this->db->where('t1.StaffID', $EmpId); + // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + $responseDetails = $this->db->get()->first_row(); + $result['empStatus'] = true; + // print_r($responseDetails->ListCode);exit(); + + if ($responseDetails->ListCode == SUPER_ADMIN) { + // print_r($result['details']->ListCode);exit(); + // get branch details for super admin + $responseDetails->BranchCode = 'All'; + $result['details'] = $responseDetails; + // print_r($result['details']);exit(); + $this->db->select('t3.BranchCode, t3.BranchName'); + $this->db->from('' . STAFF_BRANCH . ' as t2'); + $this->db->where('t2.StaffID', $EmpId); + $this->db->where('t2.IsActive', 1); + $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT'); + $this->db->where('t3.IsActive', 1); + // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + $branchDetails = $this->db->get(); + $getArrs = $branchDetails->result(); + $SS['BranchCode'] = 'All'; + $SS['BranchName'] = 'All'; + + array_push($getArrs, $SS); + // print_r($getArrs);exit(); + $result['branchStatus'] = true; + $result['branch_details'] = $getArrs; + $result['work_State'] = 'Super Admin'; + + } else { + // get branch details for admin & staff + $result['details'] = $responseDetails; + $this->db->select('t3.BranchCode, t3.BranchName'); + $this->db->from('' . STAFF_BRANCH . ' as t2'); + $this->db->where('t2.StaffID', $EmpId); + $this->db->where('t2.IsActive', 1); + $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT'); + $this->db->where('t3.IsActive', 1); + // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + $branchDetails = $this->db->get(); + $result['branchStatus'] = true; + $result['work_State'] = $responseDetails->ListCode == ADMIN ? 'Admin' : 'Staff'; + $result['branch_details'] = $branchDetails->result(); + } + } else { + $result['empStatus'] = false; + $result['message'] = "Something Went Wrong, Please try Again !!"; + } + return $result; + } // get single employee details public function get_emp_detail($empLoginID = null) @@ -400,6 +462,16 @@ class Employee_model extends CI_Model $getUploadStatus = $this->upload_image($imageSource, $imageSize, $target); $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg'; $empArr['ProfilePicPath'] = "employee/".$imageNameDb; + $this->db->select('ProfilePicPath'); + $this->db->from(STAFF); + $this->db->where('StaffID', $updateFor); + $roleDetails = $this->db->get()->first_row(); + // echo $roleDetails->ProfilePicPath; + // exit(); + if( $roleDetails->ProfilePicPath != '' && $roleDetails->ProfilePicPath != 'employee/default.jpeg'){ + unlink('../images/'.$roleDetails->ProfilePicPath); + } else { + } $this->db->where('StaffID', $updateFor); $this->db->update(STAFF, $empArr); if ($this->db->affected_rows() == '1') { diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php index 5f35c7ec..be657c73 100755 --- a/Apollo/api/application/models/Student_model.php +++ b/Apollo/api/application/models/Student_model.php @@ -253,28 +253,35 @@ class Student_model extends CI_Model } // add student - public function add_student($Arr, $courseArr) + public function add_student($Arr, $courseArr, $imagename, $imageSource, $size) { - // 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( $imageSource == '') { // add employee without image + $imageNameDb = 'default.jpeg'; + $Arr['ProfilePicPath'] = "student/".$imageNameDb; + // 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') { - $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); + $this->db->insert(STUDENTCOURSE, $courseArr); if ($this->db->affected_rows() == '1') { - $result['addStudentStatus'] = true; - $result['message'] = "Successfully student details added"; + $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"; @@ -284,8 +291,41 @@ class Student_model extends CI_Model $result['message'] = "Something went wrong.please try again"; } } else { - $result['addStudentStatus'] = false; - $result['message'] = "Something went wrong.please try again"; + $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->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; } @@ -345,31 +385,68 @@ class Student_model extends CI_Model return $result; } // update student personal details - public function update_student($empArr, $updateFor) + public function update_student($empArr, $updateFor, $imagename, $imageSource, $size) { - // 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"; + if( $imageSource == '') { + // 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"; + } + } 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"; + $result['message'] = "Something went wrong.please try again"; } - } else { - $result['updateStuStatus'] = false; - $result['message'] = "Something went wrong.please try again"; - } + } return $result; } @@ -400,4 +477,20 @@ class Student_model extends CI_Model 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; + } + } + } \ No newline at end of file diff --git a/Apollo/assets/i18n/en.json b/Apollo/assets/i18n/en.json index 1f699138..18cbfa1d 100755 --- a/Apollo/assets/i18n/en.json +++ b/Apollo/assets/i18n/en.json @@ -105,6 +105,9 @@ "MAIN": "ANNOUNCEMENT", "ANNOUNCEMENTLISTING": "ANNOUNCEMENT LISTING", "ADDANNOUNCEMENT": "ADD ANNOUNCEMENT" + }, + "profile": { + "MAIN": "MY PROFILE" } } }, diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index d86de6fb..7cceb0b2 100755 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -73,6 +73,10 @@ app.constant('JS_REQUIRES', { * Session */ 'sessionCtrl': 'assets/js/controllers/sessionCtrl.js', + /*** + * My Profile + */ + 'myProfileCtrl': 'assets/js/controllers/myProfileCtrl.js', /* * Branch * */ diff --git a/Apollo/assets/js/config.router.js b/Apollo/assets/js/config.router.js index 964b0191..cb90ce6f 100755 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -65,6 +65,14 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com ncyBreadcrumb: { label: 'Dashboard' } + }).state('app.myprofile',{ + url: "/myProfile", + templateUrl: "assets/views/myProfile/myProfile.html", + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'ngTable', 'myProfileCtrl'), + title: "My Profile", + ncyBreadcrumb: { + label: 'My Profile' + } }).state('app.changePassword', { url: "/changePassword", templateUrl: "assets/views/changePassword.html", diff --git a/Apollo/assets/js/controllers/myProfileCtrl.js b/Apollo/assets/js/controllers/myProfileCtrl.js new file mode 100644 index 00000000..357e2f55 --- /dev/null +++ b/Apollo/assets/js/controllers/myProfileCtrl.js @@ -0,0 +1,70 @@ +'use strict'; +/*** controller for Wizard Form example***/ +app.controller('myProfileCtrl', ["$scope", "$filter", "ngTableParams", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', function ($scope, $filter, ngTableParams, apiPoint, $http, SweetAlert, $state, md5, ipCookie) { + + /** + * Logined user profile view + * by : kdk + */ + var localDetail = JSON.parse(localStorage.getItem('localObj')); + var localDetails = ipCookie('cookiechk'); + + $scope.init = function () { + if (localDetail != null) { + $scope.getProfile(); + } else { + } + } + + $scope.loginUser = { + 'staffID': '', + 'fName': '', + 'lName': '', + 'mobileNumber': '', + 'gender': '', + 'branchCode': '', + 'branchList': '', + }; + + + // client side logined details + $scope.getProfile = function () { + var req = { + method: 'POST', + url: apiPoint.url + 'employeeGetProf/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + employeeLoginID: localDetails.localUserID + } + }; + $http(req).then(function (response) { + if (response.data.empStatus == true) { + /* + * Get Top Nav user details + */ + $scope.userInfo = response.data.details; + $scope.userStatusInfo = response.data.work_State; + $scope.userBranchInfo = response.data.branch_details; + // alert(JSON.stringify($scope.userInfo)); + // alert(JSON.stringify($scope.userStatusInfo)); + // alert(JSON.stringify($scope.userBranchInfo)); + // $scope.loginImage = $scope.resultData.ProfilePicPath; + // $scope.loginUser = { + // 'staffID': $scope.resultData.StaffID, + // 'fName': $scope.resultData.Firstname, + // 'lName': $scope.resultData.Lastname, + // 'mobileNumber': $scope.resultData.MobileNumber, + // 'gender': $scope.resultData.Gender, + // 'branchCode': $scope.resultData.BranchCode, + // 'branchList': response.data.branch_details, + // }; + // var currArr = response.data.branch_details; + // $scope.getCurrentBran = currArr.find(item => item.BranchCode === localDetails.localBranchID); + } else { + } + }); + }; + +}]); diff --git a/Apollo/assets/js/controllers/studentCtrl.js b/Apollo/assets/js/controllers/studentCtrl.js index 18c82989..abd6d383 100755 --- a/Apollo/assets/js/controllers/studentCtrl.js +++ b/Apollo/assets/js/controllers/studentCtrl.js @@ -4,7 +4,7 @@ * Simple table with sorting and filtering on AngularJS */ -app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$http", "API_POINTS", "$state", '$rootScope', '$cookies', 'md5', 'ipCookie', '$timeout', '$window', function ($scope, toaster, $filter, ngTableParams, $http, apiPoint, $state, $rootScope, $cookies, md5, ipCookie, $timeout, $window) { +app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$http", "API_POINTS", "$state", '$rootScope', '$cookies', 'md5', 'ipCookie', '$timeout', '$window', "flowFactory", function ($scope, toaster, $filter, ngTableParams, $http, apiPoint, $state, $rootScope, $cookies, md5, ipCookie, $timeout, $window, flowFactory) { /** * student details capture * by : kdk @@ -87,16 +87,12 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", $scope.currentDate = new Date(sixteenYearsBeforeNow); $scope.getStudentList(); $scope.getUniversityList(); - $scope.myModel.dateofbirth=$filter('date')($scope.currentDate, 'dd-MM-yyyy'); - } else { } } - - $scope.getStudentList = function () { $scope.loader = true; var empListreq = { @@ -269,7 +265,7 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } // update sutdent course details - $scope.updateStudentCourseDetails = function (form, datas) { + $scope.updateStudentCourseDetails = function (form, datas, hidedoj) { if (form.$invalid) { var field = null, firstError = null; for (field in form) { @@ -289,7 +285,7 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", var formate = "dd-MM-yyyy"; var checkDOJ = $filter('date')(new Date(datas.DOJ), formate); datas.IsActive = datas.IsActive === true ? 1 : 0; - datas.DOJ = checkDOJ == "NaN-NaN-0NaN" ? datas.DOJ : $filter('date')(new Date(datas.DOJ), formate); + datas.DOJ = datas.DOJ == hidedoj ? datas.DOJ : $filter('date')(new Date(datas.DOJ), formate); // alert(datas.DOJ); var req = { method: 'POST', @@ -448,6 +444,46 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }); } + //--------------------------------------------------------------> + // getting for image to show + //--------------------------------------------------------------> + + $scope.stepsModel = []; + $scope.imageUpload = function (event) { + var files = event.target.files; //FileList object + + for (var i = 0; i < files.length; i++) { + var file = files[i]; + var reader = new FileReader(); + reader.onload = $scope.imageIsLoaded; + reader.readAsDataURL(file); + } + } + + $scope.imageIsLoaded = function (e) { + $scope.$apply(function () { + // $scope.stepsModel.push(e.target.result); + $scope.stepsModel[0] = e.target.result; + }); + } + + //an array of files selected + $scope.files = []; + + //listen for the file selected event + $scope.$on("fileSelected", function (event, args) { + $scope.$apply(function () { + //add the file object to the scope's files collection + $scope.files[0] = args.file; + }); + }); + + // reset image + $scope.resetImage = function () { + $scope.files.length = 0; + $scope.stepsModel.length = 0; + } + // add student $scope.studentFORM = { submit: function (form, myModel, myModelCourseAdd) { @@ -471,7 +507,33 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", var formate = "dd-MM-yyyy"; $scope.myModel.switchsetting = $scope.myModel.switchsetting === true ? 1 : 0; $scope.myModel.dateofbirth = $filter('date')(new Date($scope.myModel.dateofbirth), formate); - $scope.myModelCourseAdd.dateofjoining = $filter('date')(new Date($scope.myModelCourseAdd.dateofjoining), formate); + $scope.myModelCourseAdd.dateofjoining = $filter('date')(new Date($scope.myModelCourseAdd.dateofjoining), formate); + var idStuProof = $scope.files[0]; + + if (idStuProof !== undefined) { + var formData = new FormData(); + var idProof = $scope.files[0]; + // alert(idProof); + formData.append("data", JSON.stringify($scope.myModel)); + formData.append("coursedata", JSON.stringify($scope.myModelCourseAdd)); + formData.append("createdBy", localDetails.localUserID); + formData.append("loginBranch", localDetails.localBranchID); + formData.append('idStuProof', idStuProof); + + $http.post(apiPoint.url + 'insertStudentImg/', formData, { + transformRequest: angular.identity, + headers: { 'Content-Type': undefined, 'Process-Data': false }, + }).success(function (data) { + if (data.addStudentStatus == true) { + swal("Success!", data.message, "success"); + $scope.disableButton = false; + $state.go($state.current, {}, { reload: true }); + } else { + // $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Failed!", data.message, "error"); + } + }); + } else { var req = { method: 'POST', url: apiPoint.url + 'insertStudent/', @@ -495,6 +557,7 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", swal("Failed!", response.data.message, "error"); } }); + } } }, reset: function (form) { @@ -582,8 +645,46 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }); } + + + $scope.stepsModelEdit = []; + $scope.imageUploadEdit = function (event) { + var files = event.target.files; //FileList object + + for (var i = 0; i < files.length; i++) { + var file = files[i]; + var reader = new FileReader(); + reader.onload = $scope.imageIsLoadedEdit; + reader.readAsDataURL(file); + } + } + + $scope.imageIsLoadedEdit = function (e) { + $scope.$apply(function () { + // $scope.stepsModel.push(e.target.result); + $scope.stepsModelEdit[0] = e.target.result; + }); + } + + //an array of files selected + $scope.filesEdit = []; + //listen for the file selected event + $scope.$on("fileSelectedEdit", function (event, args) { + $scope.$apply(function () { + //add the file object to the scope's files collection + $scope.filesEdit[0] = args.file; + }); + }); + + + // reset image for Edit + $scope.resetImageEdit = function () { + $scope.filesEdit.length = 0; + $scope.stepsModelEdit.length = 0; + } + // update student details - $scope.updateStuDetails = function (form, p) { + $scope.updateStuDetails = function (form, p ,hidedob) { var firstError = null; if (form.$invalid) { var field = null, firstError = null; @@ -601,11 +702,16 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", // swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error"); } else { // alert(p.DOB); + var idProof = $scope.filesEdit[0]; + var formate = "dd-MM-yyyy"; var checkDOB = $filter('date')(new Date(p.DOB), formate); p.IsActive = p.IsActive === true ? 1 : 0; - p.DOB = checkDOB == "NaN-NaN-0NaN" ? p.DOB : $filter('date')(new Date(p.DOB), formate); - var req = { + p.DOB = p.DOB == hidedob ? p.DOB : $filter('date')(new Date(p.DOB), formate); + + if(idProof == undefined) { + // alert(idProof); + var req = { method: 'POST', url: apiPoint.url + 'updateStudentExistDetail/', headers: { @@ -615,20 +721,75 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", data: p, updatedBy: localDetails.localUserID, } - }; - $http(req).then(function (response) { - if (response.data.updateStuStatus = true) { - swal("Success!", response.data.message, "success"); - $scope.getStudentList(); - $scope.editId = -1; - } else { - // $scope.ldloading1[loading.replace('-', '_')] = false; - swal("Failed!", response.data.message, "error"); - } - }); + }; + $http(req).then(function (response) { + if (response.data.updateStuStatus = true) { + swal("Success!", response.data.message, "success"); + $scope.getStudentList(); + $scope.editId = -1; + } else { + // $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Failed!", response.data.message, "error"); + } + }); + } else { + var formData = new FormData(); + var idStuUpProof = $scope.filesEdit[0]; + // alert(idProof); + formData.append("data", JSON.stringify(p)); + formData.append("updatedBy", localDetails.localUserID); + formData.append('idStuUpProof', idStuUpProof); + + $http.post(apiPoint.url + 'updateStudentImgDetails/', formData, { + transformRequest: angular.identity, + headers: { 'Content-Type': undefined, 'Process-Data': false }, + }).success(function (data) { + if (data.updateStuStatus == true) { + swal("Success!", data.message, "success"); + $scope.getStudentList(); + $scope.editId = -1; + } else { + // $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Failed!", data.message, "error"); + } + }); + } } } +}]); + +// file upload directive +app.directive('fileUpload', function () { + return { + scope: true, //create a new scope + link: function (scope, el, attrs) { + el.bind('change', function (event) { + var files = event.target.files; + //iterate files since 'multiple' may be specified on the element + for (var i = 0; i < files.length; i++) { + //emit event upward + scope.$emit("fileSelected", { file: files[i] }); + } + }); + } + }; +}); -}]); \ No newline at end of file +// file upload directive +app.directive('fileUploadEdit', function () { + return { + scope: true, //create a new scope + link: function (scope, el, attrs) { + el.bind('change', function (event) { + var files = event.target.files; + //iterate files since 'multiple' may be specified on the element + for (var i = 0; i < files.length; i++) { + //emit event upward + scope.$emit("fileSelectedEdit", { file: files[i] }); + } + }); + } + }; +}); diff --git a/Apollo/assets/views/myProfile/myProfile.html b/Apollo/assets/views/myProfile/myProfile.html new file mode 100644 index 00000000..93687c56 --- /dev/null +++ b/Apollo/assets/views/myProfile/myProfile.html @@ -0,0 +1,146 @@ + +
+
+
+

{{ mainTitle }}

+
+
+
+
+ + +
+
+
+ +
+ + + + +
+
+
+
+ +
+
+
+ img + img +
+
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
General information
Mobile Number : {{userInfo.MobileNumber}}
Alternate Mobile Number : {{userInfo.AlternateNumber}}
Email : {{userInfo.EmailID}}
Father Name : {{userInfo.Fathername}}
Mother Name : {{userInfo.MotherName}}
Gender : {{userInfo.Gender}}
Date Of Birth : {{userInfo.DOB}}
Aadhar Number : {{userInfo.AadharNumber}}
Qualification : {{userInfo.Qualification}}
Present Address : {{userInfo.PresentAddress}}
Permanent Address : {{userInfo.PermanentAddress}}
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
Branch Details
Role : {{ userStatusInfo }}
Date Of Joining : {{userInfo.DOJ}}
Branch Access :
  • {{ branch.BranchName }}
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/Apollo/assets/views/partials/nav.html b/Apollo/assets/views/partials/nav.html index 985abb0d..baaa7acb 100755 --- a/Apollo/assets/views/partials/nav.html +++ b/Apollo/assets/views/partials/nav.html @@ -105,6 +105,19 @@ +
  • + +
    +
    + +
    +
    + MY PROFILE +
    +
    +
    + +
  • @@ -208,6 +221,19 @@ +
  • + +
    +
    + +
    +
    + MY PROFILE +
    +
    +
    + +
  • diff --git a/Apollo/assets/views/partials/top-navbar.html b/Apollo/assets/views/partials/top-navbar.html index ff68a8c7..db89bfbb 100755 --- a/Apollo/assets/views/partials/top-navbar.html +++ b/Apollo/assets/views/partials/top-navbar.html @@ -136,7 +136,7 @@