parent
e40d8f7192
commit
b7f3f4315b
@ -1,183 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* View (MVC patter) for thematic control |
||||
* @author Christian Fasanando <christian1827@gmail.com> |
||||
* @package chamilo.attendance |
||||
*/ |
||||
|
||||
// protect a course script |
||||
api_protect_course_script(true); |
||||
|
||||
|
||||
if (api_is_allowed_to_edit(null, true)) { |
||||
$param_gradebook = ''; |
||||
if (isset($_SESSION['gradebook'])) { |
||||
$param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']); |
||||
} |
||||
echo '<div class="actions" style="margin-bottom:30px">'; |
||||
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_details">'.Display::return_icon('view_table.gif',get_lang('ThematicDetails')).' '.get_lang('ThematicDetails').'</a>'; |
||||
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_list">'.Display::return_icon('view_list.gif',get_lang('ThematicList')).' '.get_lang('ThematicList').'</a>'; |
||||
if ($action == 'thematic_list') { |
||||
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_add">'.Display::return_icon('introduction_add.gif',get_lang('NewThematicSection')).' '.get_lang('NewThematicSection').'</a>'; |
||||
} |
||||
echo '</div>'; |
||||
} |
||||
|
||||
if ($action == 'thematic_list') { |
||||
|
||||
echo '<div><strong>'.get_lang('ThematicList').'</strong></div><br />'; |
||||
|
||||
$table = new SortableTable('thematic_list', array('Thematic', 'get_number_of_thematics'), array('Thematic', 'get_thematic_data')); |
||||
$table->set_additional_parameters($parameters); |
||||
$table->set_header(0, '', false, array('style'=>'width:20px;')); |
||||
$table->set_header(1, get_lang('Title'), false ); |
||||
if (api_is_allowed_to_edit(null, true)) { |
||||
$table->set_header(2, get_lang('Actions'), false,array('style'=>'text-align:center;width:40%;')); |
||||
$table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics'))); |
||||
} |
||||
$table->display(); |
||||
|
||||
} else if ($action == 'thematic_details') { |
||||
|
||||
// display title |
||||
if (!empty($thematic_id)) { |
||||
echo '<div><strong>'.$thematic_data[$thematic_id]['title'].': '.get_lang('Details').'</strong></div><br />'; |
||||
} else { |
||||
echo '<div><strong>'.get_lang('ThematicDetails').'</strong></div><br />'; |
||||
// display information |
||||
$message = '<strong>'.get_lang('Information').'</strong><br />'; |
||||
$message .= get_lang('ThematicDetailsDescription'); |
||||
Display::display_normal_message($message, false); |
||||
echo '<br />'; |
||||
} |
||||
|
||||
// display thematic data |
||||
if (!empty($thematic_data)) { |
||||
|
||||
// display progress |
||||
if (!empty($thematic_id)) { |
||||
echo '<div style="text-align:right;">'.get_lang('Progress').': <strong>'.$total_average_of_advances.'</strong>%</div><br />'; |
||||
} else { |
||||
echo '<div style="text-align:right;">'.get_lang('Progress').': <strong><span id="div_result">'.$total_average_of_advances.'</span></strong>%</div><br />'; |
||||
} |
||||
|
||||
echo '<table width="100%" class="data_table">'; |
||||
echo '<tr><th width="35%">'.get_lang('Thematic').'</th><th width="30%">'.get_lang('ThematicPlan').'</th><th width="25%">'.get_lang('ThematicAdvance').'</th></tr>'; |
||||
|
||||
foreach ($thematic_data as $thematic) { |
||||
echo '<tr>'; |
||||
|
||||
// display thematic data |
||||
echo '<td><div><strong>'.$thematic['title'].'</strong></div><div>'.$thematic['content'].'</div></td>'; |
||||
|
||||
// display thematic plan data |
||||
echo '<td>'; |
||||
if (api_is_allowed_to_edit(null, true)) { |
||||
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('lp_quiz.png',get_lang('EditThematicPlan'),array('style'=>'vertical-align:middle')).'</a></div><br />'; |
||||
} |
||||
if (!empty($thematic_plan_data[$thematic['id']])) { |
||||
foreach ($thematic_plan_data[$thematic['id']] as $thematic_plan) { |
||||
echo '<div><strong>'.$thematic_plan['title'].'</strong></div><div>'.$thematic_plan['description'].'</div>'; |
||||
} |
||||
} else { |
||||
echo '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>'; |
||||
} |
||||
echo '</td>'; |
||||
|
||||
// display thematic advance data |
||||
echo '<td>'; |
||||
if (api_is_allowed_to_edit(null, true)) { |
||||
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_advance_list&thematic_id='.$thematic['id'].$param_gradebook.'">'.Display::return_icon('lp_quiz.png',get_lang('EditThematicAdvance'),array('style'=>'vertical-align:middle')).'</a></div><br />'; |
||||
} |
||||
echo '<table width="100%">'; |
||||
|
||||
if (!empty($thematic_advance_data[$thematic['id']])) { |
||||
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) { |
||||
echo '<tr>'; |
||||
echo '<td width="90%">'; |
||||
echo '<div><strong>'.api_get_local_time($thematic_advance['start_date']).'</strong></div>'; |
||||
echo '<div>'.$thematic_advance['content'].'</div>'; |
||||
echo '<div>'.get_lang('DurationInHours').' : '.$thematic_advance['duration'].'</div>'; |
||||
echo '</td>'; |
||||
if (empty($thematic_id) && api_is_allowed_to_edit(null, true)) { |
||||
$checked = ''; |
||||
if ($last_done_thematic_advance == $thematic_advance['id']) { |
||||
$checked = 'checked'; |
||||
} |
||||
$style = ''; |
||||
if ($thematic_advance['done_advance'] == 1) { |
||||
$style = ' style="background-color:#E5EDF9" '; |
||||
} else { |
||||
$style = ' style="background-color:#fff" '; |
||||
} |
||||
echo '<td id="td_done_thematic_'.$thematic_advance['id'].'" '.$style.'><center><input type="radio" id="done_thematic_'.$thematic_advance['id'].'" name="done_thematic" value="'.$thematic_advance['id'].'" '.$checked.' onclick="update_done_thematic_advance(this.value)"></center></td>'; |
||||
} else { |
||||
if ($thematic_advance['done_advance'] == 1) { |
||||
echo '<td><center>'.get_lang('Done').'</center></td>'; |
||||
} else { |
||||
echo '<td><center>-</center></td>'; |
||||
} |
||||
} |
||||
echo '</tr>'; |
||||
} |
||||
} else { |
||||
echo '<tr><td width="90%"><div><em>'.get_lang('ThereIsNoAThematicAdvance').'</em></div></td><td> </td>'; |
||||
} |
||||
echo '</table>'; |
||||
|
||||
echo '</td>'; |
||||
echo '</tr>'; |
||||
} |
||||
|
||||
echo '</table>'; |
||||
} else { |
||||
echo '<div><em>'.get_lang('ThereIsNoAThematicSection').'</em></div>'; |
||||
} |
||||
|
||||
} else if ($action == 'thematic_add' || $action == 'thematic_edit') { |
||||
|
||||
if (!$error) { |
||||
$token = md5(uniqid(rand(),TRUE)); |
||||
$_SESSION['thematic_token'] = $token; |
||||
} |
||||
|
||||
// error messages |
||||
if ($error) { |
||||
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false); |
||||
} |
||||
|
||||
$header_form = get_lang('NewThematicSection'); |
||||
if ($action == 'thematic_edit') { |
||||
$header_form = get_lang('EditThematicSection'); |
||||
} |
||||
|
||||
// display form |
||||
$form = new FormValidator('thematic_add','POST','index.php?action=thematic_list&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"'); |
||||
|
||||
$form->addElement('header', '', $header_form); |
||||
$form->addElement('hidden', 'thematic_token',$token); |
||||
$form->addElement('hidden', 'action', $action); |
||||
|
||||
if (!empty($thematic_id)) { |
||||
$form->addElement('hidden', 'thematic_id',$thematic_id); |
||||
} |
||||
|
||||
$form->add_textfield('title', get_lang('Title'), true, array('size'=>'50')); |
||||
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '250')); |
||||
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>'); |
||||
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); |
||||
|
||||
if (!empty($thematic_data)) { |
||||
// set default values |
||||
$default['title'] = $thematic_data['title']; |
||||
$default['content'] = $thematic_data['content']; |
||||
$form->setDefaults($default); |
||||
} |
||||
|
||||
$form->display(); |
||||
|
||||
} |
||||
|
||||
?> |
@ -1,139 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* View (MVC patter) for thematic advance |
||||
* @author Christian Fasanando <christian1827@gmail.com> |
||||
* @package chamilo.attendance |
||||
*/ |
||||
|
||||
// protect a course script |
||||
api_protect_course_script(true); |
||||
|
||||
|
||||
|
||||
if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { |
||||
|
||||
$header_form = get_lang('NewThematicAdvance'); |
||||
if ($action == 'thematic_advance_edit') { |
||||
$header_form = get_lang('EditThematicAdvance'); |
||||
} |
||||
|
||||
if (!$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().$param_gradebook,'','style="width: 100%;"'); |
||||
$form->addElement('header', '', $header_form); |
||||
$form->addElement('hidden', 'thematic_advance_token',$token); |
||||
$form->addElement('hidden', 'action', $action); |
||||
|
||||
if (!empty($thematic_advance_id)) { |
||||
$form->addElement('hidden', 'thematic_advance_id',$thematic_advance_id); |
||||
} |
||||
if (!empty($thematic_id)) { |
||||
$form->addElement('hidden', 'thematic_id',$thematic_id); |
||||
} |
||||
|
||||
$radios = array(); |
||||
|
||||
$radios[] = FormValidator::createElement('radio', 'start_date_type', null, get_lang('StartDateFromAnAttendance'),'1',array('onclick' => 'check_per_attendance(this)', 'id'=>'from_attendance')); |
||||
$radios[] = FormValidator::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) { |
||||
$form->addElement('html', '<div id="div_custom_datetime" style="display:block">'); |
||||
} else { |
||||
$form->addElement('html', '<div id="div_custom_datetime" style="display:none">'); |
||||
} |
||||
|
||||
$form->addElement('datepicker', 'custom_start_date', get_lang('StartDate'), array('form_name'=>'thematic_advance')); |
||||
$form->addElement('html', '</div>'); |
||||
|
||||
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">'); |
||||
} |
||||
|
||||
if (count($attendance_select) > 1) { |
||||
$form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)')); |
||||
} else { |
||||
$form->addElement('html', '<div class="row"><div class="label">'.get_lang('Attendances').'</div><div class="formw"><em>'.get_lang('ThereAreNoAttendancesInsideCourse').'</em></div></div>'); |
||||
} |
||||
|
||||
$form->addElement('html', '<div id="div_datetime_attendance">'); |
||||
if (!empty($calendar_select)) { |
||||
$form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select); |
||||
} |
||||
$form->addElement('html', '</div>'); |
||||
|
||||
$form->addElement('html', '</div>'); |
||||
$hours = range(0,24); |
||||
$form->addElement('select', 'duration_in_hours', get_lang('DurationInHours'), $hours); |
||||
|
||||
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '150')); |
||||
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>'); |
||||
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); |
||||
|
||||
$default['start_date_type'] = 1; |
||||
if (!empty($thematic_advance_data)) { |
||||
|
||||
// set default values |
||||
$default['content'] = $thematic_advance_data['content']; |
||||
$default['duration_in_hours'] = $thematic_advance_data['duration']; |
||||
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']))); |
||||
} else { |
||||
$default['start_date_type'] = 1; |
||||
if (!empty($calendar_select)) { |
||||
$default['start_date_by_attendance'] = $thematic_advance_data['start_date']; |
||||
} |
||||
$default['attendance_select'] = $thematic_advance_data['attendance_id']; |
||||
} |
||||
} |
||||
$form->setDefaults($default); |
||||
|
||||
// error messages |
||||
if ($error) { |
||||
Display::display_error_message(get_lang('YouMustSelectAtleastAStartDate'),false); |
||||
} |
||||
|
||||
$form->display(); |
||||
|
||||
} else if ($action == 'thematic_advance_list') { |
||||
|
||||
if (api_is_allowed_to_edit(null, true)) { |
||||
$param_gradebook = ''; |
||||
if (isset($_SESSION['gradebook'])) { |
||||
$param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']); |
||||
} |
||||
echo '<div class="actions" style="margin-bottom:30px">'; |
||||
echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_advance_add&thematic_id='.$thematic_id.'">'.Display::return_icon('template_add.gif',get_lang('NewThematicAdvance')).' '.get_lang('NewThematicAdvance').'</a>'; |
||||
echo '</div>'; |
||||
} |
||||
|
||||
// thematic advance list |
||||
//echo '<br /><strong>'.get_lang('ThematicAdvancesList').'</strong>'; |
||||
$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_header(0, '', false, array('style'=>'width:20px;')); |
||||
$table->set_header(1, get_lang('StartDate'), true ); |
||||
$table->set_header(2, get_lang('DurationInHours'), true, array('style'=>'width:80px;')); |
||||
$table->set_header(3, get_lang('Content'), true); |
||||
|
||||
if (api_is_allowed_to_edit(null, true)) { |
||||
$table->set_header(4, get_lang('Actions'), false,array('style'=>'text-align:center')); |
||||
//$table->set_form_actions(array ('thematic_advance_delete_select' => get_lang('DeleteAllThematicAdvances'))); |
||||
} |
||||
|
||||
$table->display(); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
?> |
@ -1,324 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This file contains class used like controller for thematic, it should be included inside a dispatcher file (e.g: index.php) |
||||
* |
||||
* !!! WARNING !!! : ALL DATES IN THIS MODULE ARE STORED IN UTC ! DO NOT CONVERT DURING THE TRANSITION FROM CHAMILO 1.8.x TO 2.0 |
||||
* |
||||
* @author Christian Fasanando <christian1827@gmail.com> |
||||
* @package chamilo.attendance |
||||
*/ |
||||
|
||||
/** |
||||
* Thematic Controller script. Prepares the common background variables to give to the scripts corresponding to |
||||
* the requested action |
||||
* @package chamilo.attendance |
||||
*/ |
||||
|
||||
class ThematicController |
||||
{ |
||||
|
||||
/** |
||||
* Constructor |
||||
*/ |
||||
public function __construct() { |
||||
$this->toolname = 'attendance'; |
||||
$this->view = new View($this->toolname); |
||||
} |
||||
|
||||
/** |
||||
* This method is used for thematic control (update, insert or listing) |
||||
* @param string Action |
||||
* render to thematic.php |
||||
*/ |
||||
public function thematic($action) { |
||||
|
||||
$thematic= new Thematic(); |
||||
$data = array(); |
||||
$error = false; |
||||
|
||||
// insert or update a thematic |
||||
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
||||
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_add' || $_POST['action'] == 'thematic_edit')) { |
||||
if (!empty($_POST['title'])) { |
||||
if ($_POST['thematic_token'] == $_SESSION['thematic_token']) { |
||||
$id = $_POST['thematic_id']; |
||||
$title = $_POST['title']; |
||||
$content = $_POST['content']; |
||||
$session_id = api_get_session_id(); |
||||
$thematic->set_thematic_attributes($id, $title, $content, $session_id); |
||||
$affected_rows = $thematic->thematic_save(); |
||||
$action = 'thematic_list'; |
||||
unset($_SESSION['thematic_token']); |
||||
} |
||||
} else { |
||||
$error = true; |
||||
$data['error'] = $error; |
||||
$data['action'] = $_POST['action']; |
||||
$data['thematic_id'] = $_POST['thematic_id']; |
||||
// render to the view |
||||
$this->view->set_data($data); |
||||
$this->view->set_layout('layout'); |
||||
$this->view->set_template('thematic'); |
||||
$this->view->render(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// delete many thematics |
||||
if ($action == 'thematic_delete_select') { |
||||
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
||||
$thematic_ids = $_POST['id']; |
||||
$affected_rows = $thematic->thematic_destroy($thematic_ids); |
||||
$action = 'thematic_list'; |
||||
} |
||||
} |
||||
|
||||
$thematic_id = isset($_GET['thematic_id'])?intval($_GET['thematic_id']):null; |
||||
|
||||
if (isset($thematic_id)) { |
||||
|
||||
// delete a thematic |
||||
if ($action == 'thematic_delete') { |
||||
$affected_rows = $thematic->thematic_destroy($thematic_id); |
||||
$action = 'thematic_list'; |
||||
} |
||||
|
||||
// move thematic |
||||
if ($action == 'moveup') { |
||||
$thematic->move_thematic('up', $thematic_id); |
||||
$action = 'thematic_list'; |
||||
} else if ($action == 'movedown') { |
||||
$thematic->move_thematic('down', $thematic_id); |
||||
$action = 'thematic_list'; |
||||
} |
||||
|
||||
$data['thematic_data'] = $thematic->get_thematic_list($thematic_id); |
||||
$data['thematic_id'] = $thematic_id; |
||||
} |
||||
|
||||
if ($action == 'thematic_details') { |
||||
|
||||
if (isset($thematic_id)) { |
||||
$thematic_data[$thematic_id] = $thematic->get_thematic_list($thematic_id); |
||||
$data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id); |
||||
} else { |
||||
$thematic_data = $thematic->get_thematic_list(); |
||||
$data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance(); |
||||
$data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances(); |
||||
} |
||||
|
||||
$thematic_plan_data = $thematic->get_thematic_plan_data(); |
||||
$thematic_advance_data = $thematic->get_thematic_advance_list(); |
||||
$data['thematic_plan_data'] = $thematic_plan_data; |
||||
$data['thematic_advance_data'] = $thematic_advance_data; |
||||
$data['thematic_data'] = $thematic_data; |
||||
} |
||||
|
||||
$data['action'] = $action; |
||||
// render to the view |
||||
$this->view->set_data($data); |
||||
$this->view->set_layout('layout'); |
||||
$this->view->set_template('thematic'); |
||||
$this->view->render(); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* This method is used for thematic plant control (update, insert or listing) |
||||
* @param string Action |
||||
* render to thematic_plan.php |
||||
*/ |
||||
public function thematic_plan($action) { |
||||
$thematic= new Thematic(); |
||||
$data = array(); |
||||
$error = false; |
||||
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
||||
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) { |
||||
if (!empty($_POST['title'])) { |
||||
if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) { |
||||
$thematic_id = $_POST['thematic_id']; |
||||
$title = $_POST['title']; |
||||
$description = $_POST['description']; |
||||
$description_type = $_POST['description_type']; |
||||
$thematic->set_thematic_plan_attributes($thematic_id, $title, $description, $description_type); |
||||
$affected_rows = $thematic->thematic_plan_save(); |
||||
unset($_SESSION['thematic_plan_token']); |
||||
$action = 'thematic_plan_list'; |
||||
} |
||||
} else { |
||||
$error = true; |
||||
$action = $_POST['action']; |
||||
$data['error'] = $error; |
||||
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']); |
||||
$data['thematic_id'] = $_POST['thematic_id']; |
||||
$data['description_type'] = $_POST['description_type']; |
||||
$data['action'] = $action; |
||||
$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); |
||||
$data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon(); |
||||
$data['default_thematic_plan_question'] = $thematic->get_default_question(); |
||||
$data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']); |
||||
|
||||
// render to the view |
||||
$this->view->set_data($data); |
||||
$this->view->set_layout('layout'); |
||||
$this->view->set_template('thematic_plan'); |
||||
$this->view->render(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($action == 'thematic_plan_list') { |
||||
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); |
||||
} |
||||
|
||||
$thematic_id = intval($_GET['thematic_id']); |
||||
$description_type = intval($_GET['description_type']); |
||||
|
||||
if (!empty($thematic_id) && !empty($description_type)) { |
||||
if ($action == 'thematic_plan_delete') { |
||||
$affected_rows = $thematic->thematic_plan_destroy($thematic_id, $description_type); |
||||
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); |
||||
$action = 'thematic_plan_list'; |
||||
} else { |
||||
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type); |
||||
} |
||||
$data['thematic_id'] = $thematic_id; |
||||
$data['description_type'] = $description_type; |
||||
} else if (!empty($thematic_id) && $action == 'thematic_plan_list') { |
||||
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); |
||||
$data['thematic_id'] = $thematic_id; |
||||
} |
||||
|
||||
$data['thematic_id'] = $thematic_id; |
||||
$data['action'] = $action; |
||||
$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); |
||||
$data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon(); |
||||
$data['next_description_type'] = $thematic->get_next_description_type($thematic_id); |
||||
$data['default_thematic_plan_question'] = $thematic->get_default_question(); |
||||
|
||||
// render to the view |
||||
$this->view->set_data($data); |
||||
$this->view->set_layout('layout'); |
||||
$this->view->set_template('thematic_plan'); |
||||
$this->view->render(); |
||||
} |
||||
|
||||
public function thematic_advance($action) { |
||||
|
||||
$thematic= new Thematic(); |
||||
$attendance = new Attendance(); |
||||
$data = array(); |
||||
|
||||
// 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']; |
||||
} |
||||
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
||||
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_advance_add' || $_POST['action'] == 'thematic_advance_edit')) { |
||||
|
||||
if ($_POST['start_date_type'] == 1 && empty($_POST['start_date_by_attendance'])) { |
||||
|
||||
$error = true; |
||||
$data['error'] = $error; |
||||
$data['action'] = $_POST['action']; |
||||
$data['thematic_id'] = $_POST['thematic_id']; |
||||
$data['attendance_select'] = $attendance_select; |
||||
|
||||
if (isset($_POST['thematic_advance_id'])) { |
||||
$data['thematic_advance_id'] = $_POST['thematic_advance_id']; |
||||
$thematic_advance_data = $thematic->get_thematic_advance_list($_POST['thematic_advance_id']); |
||||
$data['thematic_advance_data'] = $thematic_advance_data; |
||||
} |
||||
|
||||
// render to the view |
||||
$this->view->set_data($data); |
||||
$this->view->set_layout('layout'); |
||||
$this->view->set_template('thematic_advance'); |
||||
$this->view->render(); |
||||
|
||||
|
||||
} else { |
||||
if ($_POST['thematic_advance_token'] == $_SESSION['thematic_advance_token']) { |
||||
|
||||
$thematic_advance_id = $_POST['thematic_advance_id']; |
||||
$thematic_id = $_POST['thematic_id']; |
||||
$content = $_POST['content']; |
||||
|
||||
if (isset($_POST['start_date_type']) && $_POST['start_date_type'] == 2) { |
||||
$start_date = $thematic->build_datetime_from_array($_POST['custom_start_date']); |
||||
$attendance_id = 0; |
||||
} else { |
||||
$start_date = $_POST['start_date_by_attendance']; |
||||
$attendance_id = $_POST['attendance_select']; |
||||
} |
||||
|
||||
$duration = $_POST['duration_in_hours']; |
||||
$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); |
||||
} |
||||
} |
||||
|
||||
unset($_SESSION['thematic_advance_token']); |
||||
$action = 'thematic_advance_list'; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
$thematic_id = intval($_GET['thematic_id']); |
||||
$thematic_advance_id = intval($_GET['thematic_advance_id']); |
||||
$thematic_advance_data = array(); |
||||
if (!empty($thematic_advance_id)) { |
||||
if ($action == 'thematic_advance_delete') { |
||||
$affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id); |
||||
$action = 'thematic_advance_list'; |
||||
} else { |
||||
$thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id); |
||||
} |
||||
} |
||||
|
||||
// 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; |
||||
|
||||
// render to the view |
||||
$this->view->set_data($data); |
||||
$this->view->set_layout('layout'); |
||||
$this->view->set_template('thematic_advance'); |
||||
$this->view->render(); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
?> |
@ -1,110 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* View (MVC patter) for thematic plan |
||||
* @author Christian Fasanando <christian1827@gmail.com> |
||||
* @package chamilo.attendance |
||||
*/ |
||||
|
||||
// actions menu |
||||
$categories = array (); |
||||
foreach ($default_thematic_plan_title as $id => $title) { |
||||
$categories[$id] = $title; |
||||
} |
||||
$categories[ADD_THEMATIC_PLAN] = get_lang('NewBloc'); |
||||
|
||||
$i=1; |
||||
echo '<div class="actions" style="margin-bottom:30px">'; |
||||
ksort($categories); |
||||
foreach ($categories as $id => $title) { |
||||
if ($i == ADD_THEMATIC_PLAN) { |
||||
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_add&thematic_id='.$thematic_id.'&description_type='.$next_description_type.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>'; |
||||
break; |
||||
} else { |
||||
echo '<a href="index.php?action=thematic_plan_edit&'.api_get_cidreq().'&description_type='.$id.'&thematic_id='.$thematic_id.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a> '; |
||||
$i++; |
||||
} |
||||
} |
||||
echo '</div>'; |
||||
|
||||
if ($action == 'thematic_plan_list') { |
||||
|
||||
if (isset($thematic_plan_data) && count($thematic_plan_data) > 0) { |
||||
foreach ($thematic_plan_data as $thematic_plan) { |
||||
echo '<div class="sectiontitle">'; |
||||
//delete |
||||
echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_delete&description_type='.$thematic_plan['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'; |
||||
echo Display::return_icon('delete.gif', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;')); |
||||
echo '</a> '; |
||||
//edit |
||||
echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_edit&description_type='.$thematic_plan['description_type'].'">'; |
||||
echo Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;')); |
||||
echo '</a> '; |
||||
echo $thematic_plan['title']; |
||||
echo '</div>'; |
||||
echo '<div class="sectioncomment">'; |
||||
echo text_filter($thematic_plan['description']); |
||||
echo '</div>'; |
||||
} |
||||
} else { |
||||
echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>'; |
||||
} |
||||
|
||||
} else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') { |
||||
|
||||
if ($description_type >= ADD_THEMATIC_PLAN) { |
||||
$header_form = get_lang('NewBloc'); |
||||
} else { |
||||
$header_form = $default_thematic_plan_title[$description_type]; |
||||
} |
||||
|
||||
if (!$error) { |
||||
$token = md5(uniqid(rand(),TRUE)); |
||||
$_SESSION['thematic_plan_token'] = $token; |
||||
} |
||||
|
||||
// error messages |
||||
if ($error) { |
||||
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false); |
||||
} |
||||
|
||||
// display form |
||||
$form = new FormValidator('thematic_plan_add','POST','index.php?action=thematic_plan_list&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"'); |
||||
$form->addElement('header', '', $header_form); |
||||
$form->addElement('hidden', 'action', $action); |
||||
$form->addElement('hidden', 'thematic_plan_token', $token); |
||||
|
||||
if (!empty($thematic_id)) { |
||||
$form->addElement('hidden', 'thematic_id', $thematic_id); |
||||
} |
||||
if (!empty($description_type)) { |
||||
$form->addElement('hidden', 'description_type', $description_type); |
||||
} |
||||
|
||||
$form->add_textfield('title', get_lang('Title'), true, array('size'=>'50')); |
||||
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200')); |
||||
$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>'); |
||||
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); |
||||
|
||||
if ($description_type < ADD_THEMATIC_PLAN) { |
||||
$default['title'] = $default_thematic_plan_title[$description_type]; |
||||
} |
||||
if (!empty($thematic_plan_data)) { |
||||
// set default values |
||||
$default['title'] = $thematic_plan_data[0]['title']; |
||||
$default['description'] = $thematic_plan_data[0]['description']; |
||||
} |
||||
$form->setDefaults($default); |
||||
|
||||
if (isset($default_thematic_plan_question[$description_type])) { |
||||
$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />'; |
||||
$message .= $default_thematic_plan_question[$description_type]; |
||||
Display::display_normal_message($message, false); |
||||
} |
||||
|
||||
$form->display(); |
||||
} |
||||
|
||||
|
||||
?> |
Loading…
Reference in new issue