Fix PHP warnings.

1.10.x
Julio Montoya 10 years ago
parent 9c8376cd1b
commit 592d6f04d4
  1. 17
      main/attendance/attendance_sheet.php
  2. 1
      main/course_progress/layout_no_header.php
  3. 6
      main/course_progress/thematic.php
  4. 45
      main/course_progress/thematic_advance.php
  5. 23
      main/course_progress/thematic_controller.php
  6. 130
      main/inc/ajax/thematic.ajax.php
  7. 3
      main/inc/lib/events.lib.inc.php

@ -109,11 +109,11 @@ if (api_is_allowed_to_edit(null, true) ||
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.'&filter='.$default_filter.'&group_id='.$groupId.'">'.
Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
//if (count($users_in_course) > 0) {
$form->display();
//}
echo '</div>';
}
@ -398,7 +398,7 @@ if (api_is_allowed_to_edit(null, true) ||
<?php if (!$is_locked_attendance || api_is_platform_admin()) {
if (api_is_allowed_to_edit(null, true)) {
?>
<button type="submit" class="save"><?php echo get_lang('Save') ?></button>
<button type="submit" class="btn btn-primary"><?php echo get_lang('Save') ?></button>
<?php }
}
?>
@ -417,8 +417,9 @@ if (api_is_allowed_to_edit(null, true) ||
<table width="250px;">
<tr>
<td><?php echo get_lang('ToAttend').': ' ?></td>
<td><center><div class="attendance-faults-bar" style="background-color:<?php echo (!empty($faults['color_bar'])?$faults['color_bar']:'none') ?>">
<?php echo $faults['faults'].'/'.$faults['total'].' ('.$faults['faults_porcent'].'%)' ?></div></center>
<td>
<center><div class="attendance-faults-bar" style="background-color:<?php echo (!empty($faults['color_bar'])?$faults['color_bar']:'none') ?>">
<?php echo $faults['faults'].'/'.$faults['total'].' ('.$faults['faults_porcent'].'%)' ?></div></center>
</td>
</tr>
</table>
@ -442,14 +443,14 @@ if (api_is_allowed_to_edit(null, true) ||
?>
<tr class="<?php echo $class ?>">
<td>
<?php echo $presence['presence']?Display::return_icon('checkbox_on.gif',get_lang('Presence')):Display::return_icon('checkbox_off.gif',get_lang('Presence')) ?>
<?php echo $presence['presence'] ? Display::return_icon('checkbox_on.gif',get_lang('Presence')) : Display::return_icon('checkbox_off.gif',get_lang('Presence')) ?>
<?php echo "&nbsp; ".$presence['date_time'] ?>
</td>
</tr>
<?php }
} else { ?>
<tr><td>
<center><?php echo get_lang('YouDoNotHaveDoneAttendances')?></center></td>
<center><?php echo get_lang('YouDoNotHaveDoneAttendances')?></center></td>
</tr>
<?php }
?>

@ -6,6 +6,7 @@ api_protect_course_script(true);
Display :: display_reduced_header();
$tool = isset($tool) ? $tool : null;
// Tracking
Event::event_access_tool($tool);

@ -180,7 +180,7 @@ if ($action == 'thematic_list') {
$edit_link = '';
if (api_is_allowed_to_edit(null, true)) {
$edit_link = '<a class="thickbox" href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'&display=no_header" >'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array(),ICON_SIZE_SMALL).'</a>';
$edit_link = '<a class="ajax" href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'&display=no_header" >'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array(),ICON_SIZE_SMALL).'</a>';
$edit_link .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'.
Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>';
@ -253,8 +253,8 @@ if ($action == 'thematic_list') {
}
$form->addText('title', get_lang('Title'), true, array('size'=>'50'));
$form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
$form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
$form->addButtonSave(get_lang('Save'));
$show_form = true;

@ -18,15 +18,15 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$header_form = get_lang('EditThematicAdvance');
}
if (!$start_date_error && !$duration_error) {
/*if (!$start_date_error && !$duration_error) {
$token = md5(uniqid(rand(),TRUE));
$_SESSION['thematic_advance_token'] = $token;
}
}*/
// display form
$form = new FormValidator('thematic_advance','POST','index.php?action=thematic_advance_list&thematic_id='.$thematic_id.'&'.api_get_cidreq(),'','style="width: 100%;"');
$form = new FormValidator('thematic_advance','POST','index.php?action=thematic_advance_list&thematic_id='.$thematic_id.'&'.api_get_cidreq());
$form->addElement('header', $header_form);
$form->addElement('hidden', 'thematic_advance_token',$token);
//$form->addElement('hidden', 'thematic_advance_token',$token);
$form->addElement('hidden', 'action', $action);
if (!empty($thematic_advance_id)) {
@ -41,7 +41,8 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$radios[] = $form->createElement('radio', 'start_date_type', null, get_lang('StartDateCustom'),'2',array('onclick' => 'check_per_custom_date(this)', 'id'=>'custom_date'));
$form->addGroup($radios, null, get_lang('StartDateOptions'));
if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
if (isset($thematic_advance_data['attendance_id']) &&
$thematic_advance_data['attendance_id'] == 0) {
$form->addElement('html', '<div id="div_custom_datetime" style="display:block">');
} else {
$form->addElement('html', '<div id="div_custom_datetime" style="display:none">');
@ -50,7 +51,9 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$form->addElement('DatePicker', 'custom_start_date', get_lang('StartDate'));
$form->addElement('html', '</div>');
if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
if (isset($thematic_advance_data['attendance_id']) &&
$thematic_advance_data['attendance_id'] == 0
) {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:none">');
} else {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:block">');
@ -71,14 +74,12 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$form->addElement('html', '</div>');
$form->addText('duration_in_hours', get_lang('DurationInHours'), false, array('size'=>'3','id'=>'duration_in_hours_element', 'autofocus' => 'autofocus'));
$form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
//$form->addElement('textarea', 'content', get_lang('Content'));
$form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
if ($action == 'thematic_advance_add') {
$form->addElement('style_submit_button', null, get_lang('Save'), 'id="add_button" class="save"');
$form->addButtonSave(get_lang('Save'));
} else {
$form->addElement('style_submit_button', null, get_lang('Save'), 'id="update_button" class="save"');
$form->addButtonUpdate(get_lang('Save'));
}
//$form->addElement('html', '<a href="#" id="save_button" onclick="save();">Save</a>');
$attendance_select_item_id = null;
@ -103,17 +104,23 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
}
$default['start_date_type'] = 1;
$default['custom_start_date'] = date('d-F-Y H:i', api_strtotime(api_get_local_time()));
$default['custom_start_date'] = date('Y-m-d', api_strtotime(api_get_local_time()));
$default['duration_in_hours'] = 1;
if (!empty($thematic_advance_data)) {
// set default values
$default['content'] = $thematic_advance_data['content'];
$default['duration_in_hours'] = $thematic_advance_data['duration'];
$default['content'] = isset($thematic_advance_data['content']) ? $thematic_advance_data['content'] : null;
$default['duration_in_hours'] = isset($thematic_advance_data['duration']) ? $thematic_advance_data['duration'] : null;
if (empty($thematic_advance_data['attendance_id'])) {
$default['start_date_type'] = 2;
$default['custom_start_date'] = date('d-F-Y H:i', api_strtotime(api_get_local_time($thematic_advance_data['start_date'])));
$default['custom_start_date'] = null;
if (isset($thematic_advance_data['start_date'])) {
$default['custom_start_date'] = date(
'Y-m-d',
api_strtotime(api_get_local_time($thematic_advance_data['start_date']))
);
}
} else {
$default['start_date_type'] = 1;
if (!empty($thematic_advance_data['start_date'])) {
@ -127,12 +134,12 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
// error messages
$msg_error = '';
if ($start_date_error) {
/*if ($start_date_error) {
$msg_error .= get_lang('YouMustSelectAtleastAStartDate').'<br />';
}
if ($duration_error) {
$msg_error .= get_lang('DurationInHoursMustBeNumeric');
}
}*/
if (!empty($msg_error)) {
Display::display_error_message($msg_error,false);
@ -148,9 +155,9 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
}
echo '</div>';
$table = new SortableTable('thematic_advance_list', array('Thematic', 'get_number_of_thematic_advances'), array('Thematic', 'get_thematic_advance_data'));
$table->set_additional_parameters($parameters);
//$table->set_additional_parameters($parameters);
$table->set_header(0, '', false, array('style'=>'width:20px;'));
$table->set_header(1, get_lang('StartDate'), false );
$table->set_header(1, get_lang('StartDate'), false);
$table->set_header(2, get_lang('DurationInHours'), false, array('style'=>'width:80px;'));
$table->set_header(3, get_lang('Content'), false);

@ -387,16 +387,15 @@ class ThematicController
}
$thematic_id = intval($_REQUEST['thematic_id']);
$thematic_advance_id = intval($_REQUEST['thematic_advance_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)) {
$affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id);
$thematic->thematic_advance_destroy($thematic_advance_id);
}
$action = 'thematic_list';
header('Location: index.php');
exit;
}
@ -407,7 +406,7 @@ class ThematicController
exit;
}
if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) ||
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'])) {
@ -429,19 +428,17 @@ class ThematicController
$data['thematic_advance_data'] = $thematic_advance_data;
}
} else {
if ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] &&
api_is_allowed_to_edit(null, true)
) {
$thematic_advance_id = $_REQUEST['thematic_advance_id'];
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 = $_REQUEST['content'];
$duration = $_REQUEST['duration_in_hours'];
$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 = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']);
$start_date = $_REQUEST['custom_start_date'];
$attendance_id = 0;
} else {
$start_date = $_REQUEST['start_date_by_attendance'];
$attendance_id = $_REQUEST['attendance_select'];
$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,

@ -30,56 +30,56 @@ switch ($action) {
if (!api_is_allowed_to_edit(null, true)) {
echo '';
exit;
}
/*
if (($_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 (($_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;
}
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 ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) {
$thematic_advance_id = $_REQUEST['thematic_advance_id'];
$thematic_id = $_REQUEST['thematic_id'];
$content = $_REQUEST['real_content'];
$duration = $_REQUEST['duration_in_hours'];
if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
$start_date = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']);
$attendance_id = 0;
} else {
$start_date = $_REQUEST['start_date_by_attendance'];
$attendance_id = $_REQUEST['attendance_select'];
}
$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)) {
$update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance);
}
}
}
}
$thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true);
$return = $thematic->get_thematic_advance_div($thematic_advance_data);
echo $return[$_REQUEST['thematic_id']][$_REQUEST['thematic_advance_id']];*/
break;
$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 ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) {
$thematic_advance_id = $_REQUEST['thematic_advance_id'];
$thematic_id = $_REQUEST['thematic_id'];
$content = $_REQUEST['real_content'];
$duration = $_REQUEST['duration_in_hours'];
if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
$start_date = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']);
$attendance_id = 0;
} else {
$start_date = $_REQUEST['start_date_by_attendance'];
$attendance_id = $_REQUEST['attendance_select'];
}
$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)) {
$update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance);
}
}
}
}
$thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true);
$return = $thematic->get_thematic_advance_div($thematic_advance_data);
echo $return[$_REQUEST['thematic_id']][$_REQUEST['thematic_advance_id']];*/
break;
case 'get_datetime_by_attendance':
$attendance_id = intval($_REQUEST['attendance_id']);
$thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
@ -89,13 +89,13 @@ switch ($action) {
if (!empty($attendance_id)) {
$attendance = new Attendance();
$thematic = new Thematic();
$thematic_list = $thematic->get_thematic_list();
$thematic_list = $thematic->get_thematic_list();
$my_list = $thematic_list_temp = array();
foreach ($thematic_list as $item) {
$my_list = $thematic->get_thematic_advance_by_thematic_id($item['id']);
$thematic_list_temp = array_merge($my_list, $thematic_list_temp);
}
$my_list = $thematic_list_temp = array();
foreach ($thematic_list as $item) {
$my_list = $thematic->get_thematic_advance_by_thematic_id($item['id']);
$thematic_list_temp = array_merge($my_list, $thematic_list_temp);
}
$new_thematic_list = array();
foreach($thematic_list_temp as $item) {
@ -108,19 +108,19 @@ switch ($action) {
$label = get_lang('StartDate');
if (!empty($attendance_calendar)) {
$input_select .= '<select id="start_date_select_calendar" name="start_date_by_attendance" UNIQUE size="5">';
$input_select .= '<select id="start_date_select_calendar" name="start_date_by_attendance" size="5">';
foreach ($attendance_calendar as $calendar) {
$selected = null;
$selected = null;
$insert = true;
//checking if was already taken
foreach ($new_thematic_list as $key => $thematic_item) {
//if ($calendar['db_date_time'] == $thematic_item['start_date'] && $calendar['attendance_id'] == $thematic_item['attendance_id'] ) {
if ($calendar['db_date_time'] == $thematic_item['start_date'] ) {
if ($calendar['db_date_time'] == $thematic_item['start_date'] ) {
$insert = false;
if ($thematic_advance_id == $key) {
$insert = true;
$selected = 'selected';
}
if ($thematic_advance_id == $key) {
$insert = true;
$selected = 'selected';
}
break;
}
}
@ -134,12 +134,12 @@ switch ($action) {
}
}
?>
<div class="control-group">
<label class="control-label"><?php echo $label ?></label>
<div class="controls"><?php echo $input_select ?></div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $label ?></label>
<div class="col-sm-10"><?php echo $input_select ?></div>
</div>
<?php
break;
break;
case 'update_done_thematic_advance':
$thematic_advance_id = intval($_GET['thematic_advance_id']);
$total_average = 0;

@ -146,6 +146,9 @@ class Event
*/
public static function event_access_tool($tool, $id_session = 0)
{
if (empty($tool)) {
return false;
}
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$TABLETRACK_LASTACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); //for "what's new" notification

Loading…
Cancel
Save