Esempio n. 1
0
            }
        }
        ?>
		<div class="control-group">
			<label class="control-label"><?php 
        echo $label;
        ?>
</label>
			<div class="controls"><?php 
        echo $input_select;
        ?>
</div>
		</div>
		<?php 
        break;
    case 'update_done_thematic_advance':
        $thematic_advance_id = intval($_GET['thematic_advance_id']);
        $total_average = 0;
        if (!empty($thematic_advance_id)) {
            $thematic = new Thematic();
            $affected_rows = $thematic->update_done_thematic_advances($thematic_advance_id);
            //if ($affected_rows) {
            $total_average = $thematic->get_total_average_of_thematic_advances(api_get_course_id(), api_get_session_id());
            //}
        }
        echo $total_average;
        break;
    default:
        echo '';
}
exit;
Esempio n. 2
0
 /**
  * This method is used for thematic advance control (update, insert or listing)
  * render to thematic_advance.php
  * @param 	string	$action
  *
  */
 public function thematic_advance($action)
 {
     $thematic = new Thematic();
     $attendance = new Attendance();
     $data = array();
     $displayHeader = !empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header' ? false : true;
     // get data for attendance input select
     $attendance_list = $attendance->get_attendances_list();
     $attendance_select = array();
     $attendance_select[0] = get_lang('SelectAnAttendance');
     foreach ($attendance_list as $attendance_id => $attendance_data) {
         $attendance_select[$attendance_id] = $attendance_data['name'];
     }
     $thematic_id = intval($_REQUEST['thematic_id']);
     $thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? intval($_REQUEST['thematic_advance_id']) : null;
     $thematic_advance_data = array();
     switch ($action) {
         case 'thematic_advance_delete':
             if (!empty($thematic_advance_id)) {
                 if (api_is_allowed_to_edit(null, true)) {
                     $thematic->thematic_advance_destroy($thematic_advance_id);
                 }
                 header('Location: index.php');
                 exit;
             }
             break;
         case 'thematic_advance_list':
             if (!api_is_allowed_to_edit(null, true)) {
                 echo '';
                 exit;
             }
             if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance']) || !empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
                 if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) {
                     $start_date_error = true;
                     $data['start_date_error'] = $start_date_error;
                 }
                 if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
                     $duration_error = true;
                     $data['duration_error'] = $duration_error;
                 }
                 $data['action'] = $_REQUEST['action'];
                 $data['thematic_id'] = $_REQUEST['thematic_id'];
                 $data['attendance_select'] = $attendance_select;
                 if (isset($_REQUEST['thematic_advance_id'])) {
                     $data['thematic_advance_id'] = $_REQUEST['thematic_advance_id'];
                     $thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']);
                     $data['thematic_advance_data'] = $thematic_advance_data;
                 }
             } else {
                 if (api_is_allowed_to_edit(null, true)) {
                     $thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? $_REQUEST['thematic_advance_id'] : null;
                     $thematic_id = $_REQUEST['thematic_id'];
                     $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : null;
                     $duration = isset($_REQUEST['duration_in_hours']) ? $_REQUEST['duration_in_hours'] : null;
                     if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
                         $start_date = $_REQUEST['custom_start_date'];
                         $attendance_id = 0;
                     } else {
                         $start_date = isset($_REQUEST['start_date_by_attendance']) ? $_REQUEST['start_date_by_attendance'] : null;
                         $attendance_id = isset($_REQUEST['attendance_select']) ? $_REQUEST['attendance_select'] : null;
                     }
                     $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration);
                     $affected_rows = $thematic->thematic_advance_save();
                     if ($affected_rows) {
                         // get last done thematic advance before move thematic list
                         $last_done_thematic_advance = $thematic->get_last_done_thematic_advance();
                         // update done advances with de current thematic list
                         if (!empty($last_done_thematic_advance)) {
                             $thematic->update_done_thematic_advances($last_done_thematic_advance);
                         }
                     }
                 }
             }
             break;
         default:
             $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);
             break;
     }
     // get calendar select by attendance id
     $calendar_select = array();
     if (!empty($thematic_advance_data)) {
         if (!empty($thematic_advance_data['attendance_id'])) {
             $attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']);
             if (!empty($attendance_calendar)) {
                 foreach ($attendance_calendar as $calendar) {
                     $calendar_select[$calendar['date_time']] = $calendar['date_time'];
                 }
             }
         }
     }
     $data['action'] = $action;
     $data['thematic_id'] = $thematic_id;
     $data['thematic_advance_id'] = $thematic_advance_id;
     $data['attendance_select'] = $attendance_select;
     $data['thematic_advance_data'] = $thematic_advance_data;
     $data['calendar_select'] = $calendar_select;
     $layoutName = $displayHeader ? 'layout' : 'layout_no_header';
     // render to the view
     $this->view->set_data($data);
     $this->view->set_layout($layoutName);
     $this->view->set_template('thematic_advance');
     $this->view->render();
 }