public function index($advisorUserID = "all", $studentUserID = "all", $advisingLogEntryType = "all") { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isProgramChair() && !$user->isAdvisor()) { redirect('Login/logout'); } if ($advisingLogEntryType === "all") { $advisingLogEntryType = null; } if ($advisorUserID === "all") { $advisorUserID = null; } if ($user->isAdvisor() && !$user->isProgramChair() && ($advisorUserID == null || $advisorUserID != $user->getUserID())) { $advisorUserID = $user->getUserID(); } if ($studentUserID === "all") { $studentUserID = null; } $advisors = $user->isProgramChair() ? User_model::getAllAdvisors() : array($user); $students = $user->isProgramChair() ? array() : $user->getAdvisees(); $types = Advising_log_entry_model::getAllAdvisingLogEntryTypes(); $data = array('user' => $user, 'logEntries' => Advising_log_entry_model::getAllAdvisingLogEntries($advisorUserID, $studentUserID, $advisingLogEntryType), 'advisors' => $advisors, 'students' => $students, 'types' => $types, 'advisorUserID' => $advisorUserID == null ? "all" : $advisorUserID, 'studentUserID' => $studentUserID == null ? "all" : $studentUserID, 'advisingLogEntryType' => $advisingLogEntryType == null ? "all" : $advisingLogEntryType); $this->load->view('advisinglog_index_view', $data); }
public function index() { $app_Times = array(); $User_model = new User_model(); $User_model->loadPropertiesFromPrimaryKey($_SESSION['UserID']); $Advising_schedule = new Advising_schedule_model(); $Advising_appointment = new Advising_appointment_model(); $quarter = Academic_quarter_model::getLatestAcademicQuarter(); $quarter = $quarter->getAcademicQuarterID(); if ($User_model->isAdvisor()) { //If it is an advisor if ($Advising_schedule->loadPropertiesFromAdvisorIDAndAcademicQuarterID($User_model->getUserID(), $quarter)) { //if there are appointments registered to this info $All_apps = $Advising_schedule->getAllAdvisingAppointments(); //retrieve all advising appointments that correspond to this advisor $All_Advisees = $User_model->getAdvisees(); $startTime = 0; foreach ($All_apps as $key) { $startTime = $key->getStartTime(); array_push($app_Times, $startTime); } $prefs = array('all_advisees' => $All_Advisees, 'all_apps' => $All_apps, 'user' => $User_model, 'app_Times' => $app_Times, 'show_other_days' => TRUE, 'show_next_prev' => TRUE, 'next_prev_url' => site_url('Appointment_controller/index')); $Appointment_array = array('app_Times' => $app_Times, 'user' => $User_model); $this->load->library('calendar', $prefs); $this->load->view("appointment_view", $Appointment_array); //will load a blank calendar to be edited } else { //if there were no appointments found $app_Times = null; //null app_Times array $Appointment_array = array('app_Times' => $app_Times, 'user' => $User_model); $Advising_schedule->setAdvisorUserID($User_model->getUserID()); //use this to create a new advising shedule $Advising_schedule->setAcademicQuarterID($quarter); //use this to create a new advising schedule $Advising_schedule->create(); //CREATE the new advising schedule $All_Advisees = $User_model->getAdvisees(); $All_apps = $Advising_schedule->getAllAdvisingAppointments(); //for the sake o defining all_apps. It will be null $prefs = array('all_advisees' => $All_Advisees, 'all_apps' => $All_apps, 'user' => $User_model, 'app_Times' => $app_Times, 'show_other_days' => TRUE, 'show_next_prev' => TRUE, 'next_prev_url' => site_url('Appointment_controller/index')); $this->load->library('calendar', $prefs); $this->load->view("appointment_view", $Appointment_array); } } else { if ($User_model->isStudent()) { //if it is a student $getAdvisor = $User_model->getAdvisor(); //print_r ($getAdvisor); if ($Advising_schedule->loadPropertiesFromAdvisorIDAndAcademicQuarterID($getAdvisor->getUserID(), $quarter)) { $All_apps = $Advising_schedule->getAllAdvisingAppointments(); // print_r ($Appointment_array); $startTime = 0; $endTime = 0; foreach ($All_apps as $key) { $startTime = $key->getStartTime(); array_push($app_Times, $startTime); } $prefs = array('all_apps' => $All_apps, 'user' => $User_model, 'app_Times' => $app_Times, 'show_other_days' => TRUE, 'show_next_prev' => TRUE, 'next_prev_url' => 'http://localhost/index.php/appointment_controller/index'); //$app_Times=null; $Appointment_array = array('app_Times' => $app_Times, 'user' => $User_model); $this->load->library('calendar', $prefs); $this->load->view("appointment_view", $Appointment_array); //load student calendar view(which as of right now is the same as the advisor calendar view) } else { echo '<script type="text/javascript"> alert("Your advisor has not created an advising schedule!"); window.location = "Mainpage/student" </script>'; } } } }