D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
cas
/
application
/
controllers
/
admin
/
Filename :
Allotment.php
back
Copy
<?php /** * Request Handler For Allotment Modules * * @author Softpro India Pvt. Ltd. */ class Allotment extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/AllotmentManagement'); $this->load->model('admin/RoleManagement'); $this->load->model('admin/CourseManagement'); } public function assignedCourses() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allCourseAllotment'] = $this->AllotmentManagement->getAllCourseAllotment()->result(); $this->load->view('admin/academics/courseAllotments', $viewData); } else { redirect("admin/"); } } public function courseAllotment() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['roles'] = $this->RoleManagement->getNonDeletedRoles()->result(); $viewData['courses'] = $this->CourseManagement->getNonDeletedCoursesWithFullInfo()->result(); $this->load->view('admin/academics/newCourseAllotment', $viewData); } else { redirect("admin/"); } } public function saveNewCourseAllotment() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('empRole', 'Employee Role', 'trim|required', array('required' => 'Please Select Any Employee Role.')); $this->form_validation->set_rules('employee', 'Employee Name', 'trim|required', array('required' => 'Please Select Any Employee.')); $selectedCourses = $this->input->post('courses'); if ($this->form_validation->run() == FALSE) { $this->courseAllotment(); } else if (sizeof($selectedCourses) == 0) { $this->session->set_flashdata("errorMessage", "Please Select At Least One Course For Allotment."); $this->courseAllotment(); } else { $allotmentInfo = array(); $alreadyExisting = 0; for ($i = 0; $i < sizeof($selectedCourses); $i++) { if (!sizeof($this->AllotmentManagement->getCourseAllotmentInfoBy(trim($this->input->post('employee')), trim($selectedCourses[$i]))->result())) { array_push($allotmentInfo, array( 'sca_assigned_on' => date("Y-m-d H:i:s"), 'sca_assigned_by' => $this->session->userdata("adminData")["smember_id"], 'smember_id' => trim($this->input->post('employee')), 'course_id' => trim($selectedCourses[$i]) )); } else { $alreadyExisting++; } } if (sizeof($allotmentInfo)) { if ($this->AllotmentManagement->createNewCourseAllotment($allotmentInfo)) { if ($alreadyExisting) { $this->session->set_flashdata("successMessage", "Some Of The Course(s) You Selected Was Already Allotted To The Selected User However Those Which Were Not Has Been Alloted Successfully."); redirect("admin/Allotment/assignedCourses"); } else { $this->session->set_flashdata("successMessage", "Course Allotment Successful."); redirect("admin/Allotment/assignedCourses"); } } else { $this->session->set_flashdata("errorMessage", "Failed To Allot Course(s). Try Again Later."); redirect(current_url()); } } else { if ($alreadyExisting == sizeof($selectedCourses)) { $this->session->set_flashdata("errorMessage", "The Course(s) You Selected Is Already Allotted To Selected Employee."); redirect(current_url()); } else { $this->session->set_flashdata("errorMessage", "Something Went Wrong. Try Again Later."); redirect(current_url()); } } } } else { redirect("admin/"); } } public function deleteCourseAllotment($sca_id) { if ($this->sessionvalidator->isLoggedIn()) { $this->AllotmentManagement->deleteCourseAllotmentInfoBy($sca_id); $this->session->set_flashdata('successMessage', 'Course Allotment Removed Successfully.'); redirect("admin/Allotment/assignedCourses"); } else { redirect("admin/"); } } }