<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once 'course_save_script.php';
$pk_id_student = 0;
$name_student = '';
$string_student_data = '';
$courseHard = new CourseHard($registry[$nameDataBase]);
$student = new Student($registry[$nameDataBase]);
if (isset($_GET['PK_ID_COURSE_HARD'])) {
    $res = $courseHard->getListCourseHard($_GET['PK_ID_COURSE_HARD']);
    $data = $res[0];
}
if (isset($_GET['pk_id_student']) && $_GET['pk_id_student'] > 0) {
    $pk_id_student = $_GET['pk_id_student'];
    $studentData = $student->getListStudent($pk_id_student);
    $name_student = $studentData[0]['full_name'];
    $string_student_data = "&pk_id_student={$pk_id_student}";
}
$labelAdminCourses = 'Administrar Datos de Curso';
if (in_array($_SESSION['pk_id_role'], array(ROLE_TITULAR))) {
    $labelAdminCourses = "Datos de Curso";
}
if (in_array($_SESSION['pk_id_role'], array(ROLE_PROFESOR, ROLE_ESTUDIANTE))) {
    $labelAdminCourses = "Mis Datos de Curso";
}
$labelAdminMatterTeacher = 'Asignacion Materia-Profesor';
if (in_array($_SESSION['pk_id_role'], array(ROLE_ESTUDIANTE))) {
             $pk_id_evaluations_settings = $eval->getEvaluationsSettingsId(array($opcion, 3));
             break;
     }
     $note = new Note($db);
     $data_note = array($datos[7], $datos[8], $id_ballot, $pk_id_evaluations_settings, $id_matter);
     $id_note = $note->insertNote($data_note, $idTransaction);
     //adicionar la confirmacion o error del insert
     //adicionar registro de los logs
     $res = $id_note;
     //resultado final
     break;
 case 4:
     $student = new Student($db);
     $id_student = $student->getStudentId($datos[0]);
     //idStudent
     $course = new CourseHard($db);
     $id_course_hard = $course->getCourseHardId($datos[3]);
     //nombre curso
     $mcourse = new MainCourse($db);
     $id_mcourse = $mcourse->getMainCourseId($datos[3]);
     //nombre curso
     $mcourse_structure = new MCourseStructureNotes($db);
     $data_mcourse = array($id_mcourse, $opcion);
     $id_mcourse_structure = $mcourse_structure->getMCourseStructureNotesId($data_mcourse);
     $ballot = new CourseNotesBallot($db);
     $data = array($id_student, $id_course_hard, $id_mcourse_structure);
     $id_ballot = $ballot->insertCourseNotesBallot($data, $idTransaction);
     $matter = new Matter($db);
     $id_matter = $matter->getMatterId($datos[2]);
     //nombre materia
     $eval = new EvaluationsSettings($db);
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$mainCourse = new MainCourse($registry[$nameDataBase]);
$courseHard = new CourseHard($registry[$nameDataBase]);
$courseHard = new CourseHard($registry[$nameDataBase]);
$matterCourse = new AssignHCourseHardMatterTeacher($registry[$nameDataBase]);
$transaction = new Transaction($registry[$nameDataBase]);
CourseHard::setDataOperationBusiness($registry[$nameDataBase]);
$idTransaction = $transaction->insertTransaction(array(CourseHard::$business, CourseHard::$insert, CourseHard::$descriptionBusiness));
if (isset($_POST['ACTION'])) {
    if ($_POST['ACTION'] == 'INSERT' && isset($_POST['ENTITY']) && $_POST['ENTITY'] == 'COURSE_HARD') {
        //INSERCION DE NUEVO CURSO
        /*
                 
                    NAME_COURSE, DATE_START, DATE_END, 
                                                                COMMENTS_ADITIONAL, FK_ID_PERIOD, 
                                                                FK_ID_MAIN_COURSE, STATUS_COURSE_HARD, 
                  
                 * */
        $data = array($_POST['NAME_COURSE'], date('Y-m-d', strtotime(str_replace('/', '-', $_POST['DATE_START']))), date('Y-m-d', strtotime(str_replace('/', '-', $_POST['DATE_END']))), $_POST['COMMENTS_ADITIONAL'], $_POST['FK_ID_PERIOD'], $_POST['FK_ID_MAIN_COURSE'], $_POST['STATUS_COURSE_HARD']);
        $pk_id_course_hard = $courseHard->insertCourseHard($data, $idTransaction);
        $listMatterCourse = $matterCourse->getListAssignCourseMatterByCourseHard($pk_id_course_hard);
        foreach ($listMatterCourse as $item) {
            //fk_id_teacher, fk_id_main_course_matter, fk_id_course_hard
            $data = array(null, $item['pk_id_main_course_matter'], $pk_id_course_hard);
            $pk_id = $matterCourse->insertAssignHCourseHardMatterTeacher($data, $idTransaction);
        }
                    "sNext":     "Siguiente",
                    "sLast":     "Ultimo"
                }
            }});
 $(".button_form").button();
 
  $("#PERIODO").change(function() {
      var periodo = $(this).val();
      window.location.href="index.php?page=course/course_admin&PERIODO="+periodo;
  });

});
</script>
  <?php 
include_once 'course_save_script.php';
$courseHard = new CourseHard($registry[$nameDataBase]);
$list = array();
$actualPeriod = date('Y');
$period = new Period($registry[$nameDataBase]);
$listPeriod = $period->getListPeriod();
$period = 0;
foreach ($listPeriod as $per) {
    if ($per['period'] == $actualPeriod) {
        $period = $per['pk_id_period'];
    }
}
if (isset($_POST['PERIODO']) || isset($_GET['PERIODO'])) {
    $period = isset($_POST['PERIODO']) ? $_POST['PERIODO'] : $_GET['PERIODO'];
} else {
    if ($period == 0 && count($listPeriod) > 0) {
        $period = $listPeriod[0]['pk_id_period'];
 * and open the template in the editor.
 */
$action = 'INSERT';
if (isset($_GET['ACTION']) && $_GET['ACTION'] == 'EDIT') {
    $action = $_GET['ACTION'];
}
$preview_flag = 0;
$pk_id_student = 0;
$string_student_data = '';
if (isset($_GET['pk_id_student'])) {
    $pk_id_student = $_GET['pk_id_student'];
    $string_student_data = "&pk_id_student={$pk_id_student}";
} else {
    $string_student_data = "&pk_id_student=0";
}
$courseHard = new CourseHard($registry[$nameDataBase]);
$listCourses = array();
if ($_SESSION['pk_id_role'] == ROLE_TITULAR) {
    $listCourses = $courseHard->getListCourseHardByCourseANDHolderPerson($_GET['PK_ID_COURSE_HARD'], $_SESSION['pk_id_person']);
}
if ($_SESSION['pk_id_role'] == ROLE_ESTUDIANTE) {
    $listCourses = $courseHard->getListCourseHardByCourseANDStudentPerson($_GET['PK_ID_COURSE_HARD'], $_SESSION['pk_id_person']);
}
$matterCourse = new AssignHCourseHardMatterTeacher($registry[$nameDataBase]);
if (count($listCourses) > 0) {
    ?>

<form id="course_data_form" method="POST" action="?page=course/course_request_admin&ACTION=EDIT&PK_ID_COURSE_HARD=<?php 
    echo $_GET['PK_ID_COURSE_HARD'] . $string_student_data;
    ?>
" enctype="multipart/form-data" >