Moving form in the actions bar see BT#4940

skala
Julio Montoya 13 years ago
parent a1fd109974
commit 1cbef47e54
  1. 2
      main/attendance/attendance_calendar.php
  2. 56
      main/attendance/attendance_controller.php
  3. 2
      main/attendance/attendance_list.php
  4. 73
      main/attendance/attendance_sheet.php
  5. 3
      main/inc/lib/export.lib.inc.php

@ -15,7 +15,7 @@ if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
}
if (!$is_locked_attendance || api_is_platform_admin()) {
echo '<div class="actions" style="margin-bottom:30px">';
echo '<div class="actions">';
if ($action == 'calendar_add') {
echo '<a href="index.php?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendance_id.$param_gradebook.'">'.Display::return_icon('back.png',get_lang('AttendanceCalendar'),'',ICON_SIZE_MEDIUM).'</a>';
} else {

@ -174,6 +174,7 @@
}
$this->attendance_list();
}
/**
* Restores an attendance entry and fallback to attendances rendering
* @param int attendance id
@ -265,8 +266,7 @@
}
$data['users_in_course'] = $attendance->get_users_rel_course($attendance_id);
$my_calendar_id = null;
$my_calendar_id = null;
if (is_numeric($filter_type)) {
$my_calendar_id = $filter_type;
$filter_type = 'calendar_id';
@ -385,7 +385,7 @@
* @param int attendance id
*/
public function attendance_sheet_export_to_pdf($action, $attendance_id, $student_id = 0, $course_id = '') {
$attendance = new Attendance();
$courseInfo = CourseManager::get_course_information($course_id);
@ -394,7 +394,20 @@
$data_array['attendance_id'] = $attendance_id;
$data_array['users_in_course'] = $attendance->get_users_rel_course($attendance_id);
$data_array['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id);
$filter_type = 'today';
if (!empty($_REQUEST['filter'])) {
$filter_type = $_REQUEST['filter'];
}
$my_calendar_id = null;
if (is_numeric($filter_type)) {
$my_calendar_id = $filter_type;
$filter_type = 'calendar_id';
}
$data_array['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type, $my_calendar_id);
//$data_array['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id);
if (api_is_allowed_to_edit(null, true) || api_is_drh()) {
$data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id);
@ -408,10 +421,12 @@
$data_array['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id);
$data_array['user_id'] = $user_id;
}
$data_array['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
// set headers pdf
//Set headers pdf
$courseCategory = CourseManager::get_course_category($courseInfo['category_code']);
$teacherInfo = CourseManager::get_teacher_list_from_course_code($courseInfo['code']);
@ -427,9 +442,9 @@
$data_table = array();
$head_table = array('#', get_lang('Name'));
foreach ($data_array['attendant_calendar'] as $class_day) {
$head_table[] = $class_day['date'];
}
foreach ($data_array['attendant_calendar'] as $class_day) {
$head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_SHORT).' <br />'.api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT);
}
$data_table[] = $head_table;
$dataClass = array();
@ -439,7 +454,7 @@
$data_attendant_calendar = $data_array['attendant_calendar'];
$data_users_presence = $data_array['users_presence'];
$count = 1;
if (!empty($data_array['users_in_course'])) {
foreach ($data_array['users_in_course'] as $user) {
$cols = 1;
@ -449,41 +464,34 @@
foreach ($data_array['attendant_calendar'] as $class_day) {
if ($class_day['done_attendance'] == 1) {
if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1)
$result[$class_day['id']] = " . ";
$result[$class_day['id']] = get_lang('UserAttendedSymbol');
else
$result[$class_day['id']] = " F ";
$result[$class_day['id']] = get_lang('UserNotAttendedSymbol');
} else {
$result[$class_day['id']] = " \ ";
$result[$class_day['id']] = " ";
}
$cols++;
}
$count++;
$data_table[] = $result;
}
}
}
$max_cols_per_page = 12; //10 dates + 2 name and number
$max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2;//10
//var_dump($cols);exit;
$rows = count($data_table);
$rows = count($data_table);
if ($cols > $max_cols_per_page) {
$number_tables = round(($cols-2)/$max_dates_per_page);
//var_dump($number_tables);
$number_tables = round(($cols-2)/$max_dates_per_page);
$headers = $data_table[0];
//var_dump($data_table[1]);
$all = array();
$tables = array();
$changed = 1;
for ($i= 0; $i <= $rows; $i++) {
$row = $data_table[$i];
$row = $data_table[$i];
$key = 1;
$max_dates_per_page = 10;
//for ($j = 0; $j < $cols; $j++) {
$item = $data_table[$i];
$count_j = 0;
@ -510,7 +518,7 @@
}
}
} else {
$content .= Export::convert_array_to_html($data_table);
$content .= Export::convert_array_to_html($data_table, array('header_attributes' => array('align' => 'center')));
}
$params = array(

@ -15,7 +15,7 @@ if (api_is_allowed_to_edit(null, true)) {
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
}
echo '<div class="actions" style="margin-bottom:30px">';
echo '<div class="actions">';
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=attendance_add">'.Display::return_icon('new_attendance_list.png',get_lang('CreateANewAttendance'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
}

@ -16,35 +16,14 @@ if (api_is_allowed_to_edit(null, true)) {
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook'];
}
if (!$is_locked_attendance || api_is_platform_admin()) {
echo '<div class="actions" style="margin-bottom:30px">';
echo '<a href="index.php?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendance_id.$param_gradebook.'">'.
Display::return_icon('attendance_calendar.png',get_lang('AttendanceCalendar'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_export_to_pdf&attendance_id='.$attendance_id.$param_gradebook.'">'.
Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
}
$message_information = get_lang('AttendanceSheetDescription');
if (!empty($message_information)) {
$message = '<strong>'.get_lang('Information').'</strong><br />';
$message .= $message_information;
Display::display_normal_message($message, false);
}
if ($is_locked_attendance) {
Display::display_warning_message(get_lang('TheAttendanceSheetIsLocked'), false);
}
$form = new FormValidator('filter', 'post', 'index.php?action=attendance_sheet_add&'.api_get_cidreq().$param_gradebook.'&attendance_id='.$attendance_id);
$form = new FormValidator('filter', 'post', 'index.php?action=attendance_sheet_add&'.api_get_cidreq().$param_gradebook.'&attendance_id='.$attendance_id, null, array('class' => 'form-search pull-left'));
$values = array(
'all' => get_lang('All'),
'today' => get_lang('Today'),
'all_done' => get_lang('AllDone'),
'all_not_done' => get_lang('AllNotDone')
);
);
$today = api_convert_and_format_date(null, DATE_FORMAT_SHORT);
$exists_attendance_today = false;
@ -62,7 +41,7 @@ if (api_is_allowed_to_edit(null, true)) {
Display::display_warning_message(get_lang('ThereIsNoClassScheduledTodayTryPickingAnotherDay'));
}
$form->addElement('select', 'filter', get_lang('Filter'), $values);
$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
$form->addElement('style_submit_button', null, get_lang('Filter'), 'class="filter"');
if (isset($_REQUEST['filter'])) {
@ -71,14 +50,54 @@ if (api_is_allowed_to_edit(null, true)) {
}
} else {
$default_filter = 'today';
}
}
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('{label} {element} ');
$form->setDefaults(array('filter'=>$default_filter));
if (!$is_locked_attendance || api_is_platform_admin()) {
echo '<div class="actions">';
echo '<a style="float:left;" href="index.php?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendance_id.$param_gradebook.'">'.
Display::return_icon('attendance_calendar.png',get_lang('AttendanceCalendar'),'',ICON_SIZE_MEDIUM).'</a>';
if (count($users_in_course) > 0) {
$form->display();
}
echo '<a id="pdf_export" style="float:left;" href="index.php?'.api_get_cidreq().'&action=attendance_sheet_export_to_pdf&attendance_id='.$attendance_id.$param_gradebook.'">'.
Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
}
$message_information = get_lang('AttendanceSheetDescription');
if (!empty($message_information)) {
$message = '<strong>'.get_lang('Information').'</strong><br />';
$message .= $message_information;
Display::display_normal_message($message, false);
}
if ($is_locked_attendance) {
Display::display_warning_message(get_lang('TheAttendanceSheetIsLocked'), false);
}
$param_filter = '&filter='.Security::remove_XSS($default_filter);
if (count($users_in_course) > 0) {
$form->display();
?>
<script type="text/javascript">
<script>
var original_url = '';
$("#pdf_export").on('click', function() {
filter = $("#filter_id").val();
if (original_url == '') {
original_url = $(this).attr('href');
}
new_url = original_url + "&filter=" +filter
$(this).attr('href', new_url);
//console.log(new_url);
});
function UpdateTableHeaders() {
$("div.divTableWithFloatingHeader").each(function() {
var originalHeaderRow = $(".tableFloatingHeaderOriginal", this);

@ -193,8 +193,7 @@ class Export {
$headers = $data[0];
unset($data[0]);
$header_attributes = isset($params['header_attributes']) ? $params['header_attributes'] : array();
$header_attributes = isset($params['header_attributes']) ? $params['header_attributes'] : array();
$table = new HTML_Table(array('class' => 'data_table', 'repeat_header' => '1'));
$row = 0;
$column = 0;

Loading…
Cancel
Save