Attendance tool: Adding calendar dates in the filter select see BT#2498

skala
Julio Montoya 14 years ago
parent 1c705a29a2
commit 38ce4f1a69
  1. 17
      main/attendance/attendance_controller.php
  2. 24
      main/attendance/attendance_sheet.php
  3. 13
      main/inc/lib/attendance.lib.php

@ -225,7 +225,7 @@
$data['user_id'] = $user_id;
}
$data['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
$data['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
$data['next_attendance_calendar_datetime'] = $attendance->get_next_attendance_calendar_datetime($attendance_id);
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
@ -241,11 +241,20 @@
}
$data['users_in_course'] = $attendance->get_users_rel_course($attendance_id);
$data['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type);
$data['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id);
$data['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
$my_calendar_id = null;
if (is_numeric($filter_type)) {
$my_calendar_id = $filter_type;
$filter_type = 'calendar_id';
}
$data['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type, $my_calendar_id);
$data['attendant_calendar_all'] = $attendance->get_attendance_calendar($attendance_id);
$data['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id);
$data['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
$data['next_attendance_calendar_datetime'] = $attendance->get_next_attendance_calendar_datetime($attendance_id);
} else {
$data['attendant_calendar_all'] = $attendance->get_attendance_calendar($attendance_id);
$data['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id,$filter_type);
}
$data['is_locked_attendance'] = $attendance->is_locked_attendance($attendance_id);

@ -34,13 +34,26 @@ if (api_is_allowed_to_edit(null, true)) {
$form = new FormValidator('filter', 'post', 'index.php?action=attendance_sheet_add&'.api_get_cidreq().$param_gradebook.'&attendance_id='.$attendance_id);
$values = array('all'=>get_lang('All'), 'today'=>get_lang('Today'),'all_done'=>get_lang('AllDone'), 'all_not_done'=>get_lang('AllNotDone'));
$form->addElement('select', 'filter', 'Filter', $values);
$values = array('all' => get_lang('All'),
'today' => get_lang('Today'),
'all_done' => get_lang('AllDone'),
'all_not_done' => get_lang('AllNotDone')
);
if (!empty($attendant_calendar_all)) {
$values[''] = '---------------';
foreach($attendant_calendar_all as $attendance_date) {
$values[$attendance_date['id']] = $attendance_date['date_time'];
}
}
$form->addElement('select', 'filter', get_lang('Filter'), $values);
$form->addElement('style_submit_button', null, get_lang('Filter'), 'class="filter"');
if (isset($_REQUEST['filter'])) {
if (in_array($_REQUEST['filter'],array_keys($values))) {
if (isset($_REQUEST['filter'])) {
if (in_array($_REQUEST['filter'], array_keys($values))) {
$default_filter = $_REQUEST['filter'];
}
} else {
@ -102,7 +115,6 @@ if (api_is_allowed_to_edit(null, true)) {
});
</script>
<form method="post" action="index.php?action=attendance_sheet_add&<?php echo api_get_cidreq().$param_gradebook.$param_filter ?>&attendance_id=<?php echo $attendance_id?>" >
<div class="attendance-sheet-content" style="width:100%;background-color:#E1E1E1;margin-top:20px;">

@ -833,16 +833,23 @@ class Attendance
* @param int attendance id
* @return array attendance calendar data
*/
public function get_attendance_calendar($attendance_id, $type = 'all') {
public function get_attendance_calendar($attendance_id, $type = 'all', $calendar_id = null) {
global $dateFormatShort, $timeNoSecFormat;
$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$attendance_id = intval($attendance_id);
$sql = "SELECT * FROM $tbl_attendance_calendar WHERE attendance_id = '$attendance_id' ";
$filter_where = '';
if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done'))) {
if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done','calendar_id'))) {
$type = 'all';
}
switch ($type ) {
switch ($type) {
case 'calendar_id':
$calendar_id = intval($calendar_id);
if (!empty($calendar_id)) {
$sql.= " AND id = $calendar_id";
}
break;
case 'today':
//$sql .= ' AND DATE_FORMAT(date_time,"%d-%m-%Y") = DATE_FORMAT("'.api_get_utc_datetime().'", "%d-%m-%Y" )';
break;

Loading…
Cancel
Save