Skip to content

Commit

Permalink
Issue #290 - Creating page to bind teachers to the selective process
Browse files Browse the repository at this point in the history
  • Loading branch information
italopaiva committed Jan 22, 2017
1 parent 121b4eb commit 618645c
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 44 deletions.
2 changes: 2 additions & 0 deletions application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@
$route['download_notice/(:num)/(:num)'] = 'program/selectiveprocess/downloadNotice/$1/$2';
$route['define_dates_page/(:num)/(:num)'] = 'program/selectiveprocess/loadDefineDatesPage/$1/$2';
$route['define_dates/(:num)/(:num)'] = 'program/selectiveprocess/defineDates/$1/$2';
$route['selection_process/define_teachers/(:num)/(:num)'] = 'program/selectiveprocess/defineTeachers/$1/$2';
$route['selection_process/define_teacher/(:num)/(:num)'] = 'program/selectiveprocess/defineTeacher/$1/$2';

/*
* Enrollment routes
Expand Down
36 changes: 26 additions & 10 deletions application/modules/program/controllers/Selectiveprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ public function index() {
loadTemplateSafelyByPermission(PermissionConstants::SELECTION_PROCESS_PERMISSION, "program/selection_process/index", $data);
}

public function defineTeachers($processId, $programId){

$session = getSession();
$user = $session->getUserData();
$secretaryId = $user->getId();

$this->load->model('program/program_model');
$programsTeachers = $this->program_model->getProgramTeachers($programId);

$data = array(
'teachers' => $programsTeachers
);

loadTemplateSafelyByPermission(PermissionConstants::SELECTION_PROCESS_PERMISSION, "program/selection_process/define_teachers", $data);
}

public function programCourses($programId){

$session = getSession();
Expand Down Expand Up @@ -79,9 +95,9 @@ public function courseSelectiveProcesses($courseId){
$course = $this->course_model->getCourseById($courseId);

$selectiveProcesses = $this->getCourseSelectiveProcesses($courseId);

$divulgations = $this->getProcessDivulgations($selectiveProcesses);

$data = array(
'course' => $course,
'selectiveProcesses' => $selectiveProcesses,
Expand Down Expand Up @@ -153,10 +169,10 @@ private function createFolders($desiredPath, $ids){
}

public function saveNoticeFile(){

$courseId = $this->input->post("course");
$processId = base64_decode($this->input->post("selection_process_id"));

$message = $this->uploadNoticeFile($courseId, $processId);
switch ($message) {
case self::NOTICE_FILE_SUCCESS:
Expand All @@ -168,7 +184,7 @@ public function saveNoticeFile(){
$status = "danger";
$pathToRedirect = "program/selectiveprocess/tryUploadNoticeFile/{$processId}";
break;

default:
$status = "danger";
$pathToRedirect = "program/selectiveprocess/tryUploadNoticeFile/{$processId}";
Expand Down Expand Up @@ -310,7 +326,7 @@ public function edit($processId, $courseId){
$allPhases = $this->phase->getAllPhases();

$phases = $this->getProcessPhasesToEdit($selectiveProcess, $allPhases);

$noticePath = $selectiveProcess->getNoticePath();
$names = explode("/", $noticePath);
$noticeFileName = array_pop($names);
Expand All @@ -334,7 +350,7 @@ private function getProcessPhasesToEdit($selectiveProcess, $allPhases){
$phasesNames = array();
$phasesWeights = array();
$processPhases = $selectiveProcess->getSettings()->getPhases();

foreach ($allPhases as $phase) {
$hasThePhase = FALSE;
$phaseId = $phase->getPhaseId();
Expand Down Expand Up @@ -369,7 +385,7 @@ private function getProcessPhasesToEdit($selectiveProcess, $allPhases){
}

public function downloadNotice($selectiveProcessId, $courseId){

$selectiveProcess = $this->process_model->getById($selectiveProcessId);
$noticePath = $selectiveProcess->getNoticePath();
$this->load->helper('download');
Expand All @@ -385,7 +401,7 @@ public function downloadNotice($selectiveProcessId, $courseId){
}

public function loadDefineDatesPage($selectiveProcessId, $courseId){

$selectiveProcess = $this->process_model->getById($selectiveProcessId);
$processDivulgation = $this->process_model->getNoticeDivulgation($selectiveProcessId);

Expand All @@ -394,7 +410,7 @@ public function loadDefineDatesPage($selectiveProcessId, $courseId){
'courseId' => $courseId,
'processDivulgation' => $processDivulgation
);

loadTemplateSafelyByPermission(PermissionConstants::SELECTION_PROCESS_PERMISSION, "program/selection_process/define_dates", $data);
}

Expand Down
86 changes: 63 additions & 23 deletions application/modules/program/models/Program_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public function getAllPrograms(){
}

public function getAllProgramAreas(){

$allProgramAreas = $this->db->get('program_area')->result_array();

$allProgramAreas = checkArray($allProgramAreas);

return $allProgramAreas;

}

public function getProgramEvaluations($programId){

$this->db->order_by("start_year", "asc");
Expand Down Expand Up @@ -52,6 +52,46 @@ public function getCoordinatorPrograms($coordinatorId){
return $coordinatorPrograms;
}

public function getSecretaryPrograms($secretaryId){
$this->db->select('program.*');
$this->db->from('program');
$this->db->join('course', 'program.id_program = course.id_program');
$this->db->join('secretary_course', 'course.id_course = secretary_course.id_course');
$this->db->where('secretary_course.id_user', $secretaryId);

$programs = checkArray($this->db->get()->result_array());

return $programs;
}

public function getProgramTeachers($program){
$this->db->select('users.id, users.name, users.name, users.email, program.program_name');
$this->db->from('users');
$this->db->join('teacher_course', 'users.id = teacher_course.id_user');
$this->db->join('course', 'teacher_course.id_course = course.id_course');
$this->db->join('program', 'course.id_program = program.id_program');
$this->db->order_by('program.id_program', 'asc');

if(is_array($program)){
$first = TRUE;
foreach ($program as $program) {
if($first){
$this->db->where('program.id_program', $program['id_program']);
}else{
$this->db->or_where('program.id_program', $program['id_program']);
}
$first = FALSE;
}

}else{
$this->db->where('program.id_program', $program);
}

$programs = checkArray($this->db->get()->result_array());

return $programs;
}

public function getProgramCourses($programId){

$this->db->select('*');
Expand All @@ -65,11 +105,11 @@ public function getProgramCourses($programId){
}

public function parseProgramAreas($areaName){

return $this->db->insert("program_area",array("area_name"=>$areaName));

}

public function addCourseToProgram($courseId, $programId){

$course = new Course;
Expand Down Expand Up @@ -131,12 +171,12 @@ public function removeCourseFromProgram($courseId, $programId){
}

private function getProgramCourse($programId, $courseId){

$searchResult = $this->db->get_where('program_course', array('id_program' => $programId, 'id_course' => $courseId));
$foundProgramCourse = $searchResult->row_array();

$foundProgramCourse = checkArray($foundProgramCourse);

return$foundProgramCourse;
}

Expand Down Expand Up @@ -215,15 +255,15 @@ public function getProgramById($programId){

return $program;
}

public function getProgramAreaByProgramId($programId){

$program = $this->getProgram(array('id_program' => $programId));

$areaId = $program['id_area'];

$programArea = $this->getArea(array('id_program_area' => $areaId));

return $programArea;
}

Expand Down Expand Up @@ -258,7 +298,7 @@ public function getUserProgram($userId, $userGroups){
}

private function getTeacherPrograms($teacherId){

$this->db->select('id_program');
$this->db->from("course");
$this->db->join('teacher_course', 'course.id_course = teacher_course.id_course');
Expand All @@ -268,11 +308,11 @@ private function getTeacherPrograms($teacherId){
$programsIds = checkArray($programsIds);

return $programsIds;

}

private function getStudentProgram($studentId){

$this->db->select('id_program');
$this->db->from("course");
$this->db->join('course_student', 'course.id_course = course_student.id_course');
Expand All @@ -282,12 +322,12 @@ private function getStudentProgram($studentId){
$programsIds = checkArray($programsIds);

return $programsIds;

}


private function insertProgram($program){

$this->db->insert('program', $program);

$insertedProgram = $this->getProgram($program);
Expand All @@ -309,13 +349,13 @@ private function getProgram($programToSearch){

return $foundProgram;
}

private function getArea($areaToSearch){
$this->db->select('area_name');
$foundArea = $this->db->get_where('program_area', $areaToSearch)->row_array();

$foundArea = checkArray($foundArea);

return $foundArea;
}

Expand All @@ -327,7 +367,7 @@ public function countNumberOfTeachersOnProgram($programId){
$this->db->where('course.id_program', $programId);

$numberOfTeachers = $this->db->count_all_results();

return $numberOfTeachers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<div align='right'>
<i class='fa fa-eye'> Visualizar </i> &nbsp&nbsp
<i class='fa fa-edit'> Editar </i> &nbsp&nbsp
<i class='fa fa-calendar'> Definir datas </i>
<i class='fa fa-calendar'> Definir datas </i> &nbsp&nbsp
<i class='fa fa-group'> Definir docentes </i>
</div>

<?php
Expand Down Expand Up @@ -113,12 +114,14 @@
};

newModal("selectiveprocessmodal".$processId, "Processo Seletivo: <b>{$processName}</b>", $body, $footer);

echo "<a href='#selectiveprocessmodal{$processId}' data-toggle='modal' class='btn btn-success'><i class='fa fa-eye'></i></a>";
echo "&nbsp";
echo anchor("edit_selection_process/{$processId}/{$course[Course_model::ID_ATTR]}", "<i class='fa fa-edit'></i>", "class='btn btn-primary'");
echo "&nbsp";
echo anchor("define_dates_page/{$processId}/{$course[Course_model::ID_ATTR]}", "<i class='fa fa-calendar'></i>", "class='btn btn-warning'");
echo "&nbsp";
echo anchor("selection_process/define_teachers/{$processId}/{$course['id_program']}", "<i class='fa fa-group'></i>", "class='btn btn-info'");

echo "</td>";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h2 class="principal">Vincular docentes ao processo seletivo </h2>

<?php buildTableDeclaration(); ?>
<?php
buildTableHeaders([
'Nome',
'E-mail',
'Programa',
'Ações'
]);
?>

<?php if(!empty($teachers)): ?>
<?php foreach ($teachers as $teacher): ?>

<tr>
<td><?= $teacher['name'] ?></td>
<td><?= $teacher['email'] ?></td>
<td><?= $teacher['program_name'] ?></td>
<td>
<?= anchor('selection_process/define_teacher/', "<i class='fa fa-plus'></i> Vincular docente", "class='btn btn-primary'") ?>
</td>
</tr>

<?php endforeach ?>
<?php else: ?>
<?= callout('info', 'Nenhum docente cadastrado nos cursos deste programa.') ?>
<?php endif ?>

<?php buildTableEndDeclaration(); ?>

Loading

0 comments on commit 618645c

Please sign in to comment.