/**
  * It's used for editing attendace,
  * render to attendance_edit or attendance_list view
  * @param int	attendance id
  */
 public function attendance_edit($attendance_id)
 {
     $attendance = new Attendance();
     $data = array();
     $attendance_id = intval($attendance_id);
     if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
         if (!empty($_POST['title'])) {
             $check = Security::check_token();
             if ($check) {
                 $attendance->set_name($_POST['title']);
                 $attendance->set_description($_POST['description']);
                 $attendance->set_attendance_qualify_title($_POST['attendance_qualify_title']);
                 $attendance->set_attendance_weight($_POST['attendance_weight']);
                 $attendance->category_id = $_POST['category_id'];
                 $link_to_gradebook = false;
                 if (isset($_POST['attendance_qualify_gradebook']) && $_POST['attendance_qualify_gradebook'] == 1) {
                     $link_to_gradebook = true;
                 }
                 $last_id = $attendance->attendance_edit($attendance_id, $link_to_gradebook);
                 Security::clear_token();
                 $param_gradebook = '';
                 if (isset($_SESSION['gradebook'])) {
                     $param_gradebook = '&gradebook=' . Security::remove_XSS($_SESSION['gradebook']);
                 }
                 header('location:index.php?action=attendance_list&' . api_get_cidreq() . $param_gradebook);
                 exit;
             }
         } else {
             $data['attendance_id'] = $_POST['attendance_id'];
             $data['error'] = true;
             $this->view->set_data($data);
             $this->view->set_layout('layout');
             $this->view->set_template('attendance_edit');
             $this->view->render();
         }
     } else {
         // default values
         $attendance_data = $attendance->get_attendance_by_id($attendance_id);
         $data['attendance_id'] = $attendance_data['id'];
         $data['title'] = $attendance_data['name'];
         $data['description'] = $attendance_data['description'];
         $data['attendance_qualify_title'] = $attendance_data['attendance_qualify_title'];
         $data['attendance_weight'] = $attendance_data['attendance_weight'];
         $this->view->set_data($data);
         $this->view->set_layout('layout');
         $this->view->set_template('attendance_edit');
         $this->view->render();
     }
 }
Exemplo n.º 2
0
if (isset($_GET['attendance_id'])) {
    $attendance_id = intval($_GET['attendance_id']);
}
// get calendar id
$calendar_id = '';
if (isset($_GET['calendar_id'])) {
    $calendar_id = intval($_GET['calendar_id']);
}
// instance attendance object for using like library here
$attendance = new Attendance();
// attendance controller object
$attendance_controller = new AttendanceController();
// get attendance data
if (!empty($attendance_id)) {
    // attendance data by id
    $attendance_data = $attendance->get_attendance_by_id($attendance_id);
}
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = '<script>

$(function() {
	$("table th img").click(function() {
		var col_id = this.id;
		var col_split = col_id.split("_");
		var calendar_id = col_split[2];
		var class_img = $(this).attr("class");

		if (class_img == "img_unlock") {
			//lock
			$(".checkbox_head_"+calendar_id).attr("disabled", true);