attendance_edit.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for editing an attendance
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.attendance
  7. */
  8. // protect a course script
  9. api_protect_course_script(true);
  10. // error messages
  11. if (isset($error)) {
  12. echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false);
  13. }
  14. if (!isset($error)) {
  15. $token = Security::get_token();
  16. }
  17. $attendance_weight = api_float_val($attendance_weight);
  18. // display form
  19. $form = new FormValidator(
  20. 'attendance_edit',
  21. 'POST',
  22. 'index.php?action=attendance_edit&'.api_get_cidreq().'&attendance_id='.$attendance_id
  23. );
  24. $form->addElement('header', '', get_lang('Edit'));
  25. $form->addElement('hidden', 'sec_token', $token);
  26. $form->addElement('hidden', 'attendance_id', $attendance_id);
  27. $form->addText('title', get_lang('Title'), true);
  28. $form->applyFilter('title', 'html_filter');
  29. $form->addHtmlEditor(
  30. 'description',
  31. get_lang('Description'),
  32. false,
  33. false,
  34. array(
  35. 'ToolbarSet' => 'TrainingDescription',
  36. 'Width' => '100%',
  37. 'Height' => '200',
  38. )
  39. );
  40. // Adavanced Parameters
  41. if (Gradebook::is_active()) {
  42. if (!empty($attendance_qualify_title) || !empty($attendance_weight)) {
  43. $form->addButtonAdvancedSettings('id_qualify');
  44. $form->addElement('html', '<div id="id_qualify_options" style="display:block">');
  45. $form->addElement(
  46. 'checkbox',
  47. 'attendance_qualify_gradebook',
  48. '',
  49. get_lang('QualifyAttendanceGradebook'),
  50. array('checked'=>'true', 'onclick'=>'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}')
  51. );
  52. $form->addElement('html', '<div id="options_field" style="display:block">');
  53. } else {
  54. $form->addButtonAdvancedSettings('id_qualify');
  55. $form->addElement('html', '<div id="id_qualify_options" style="display:none">');
  56. $form->addElement(
  57. 'checkbox',
  58. 'attendance_qualify_gradebook',
  59. '',
  60. get_lang('QualifyAttendanceGradebook'),
  61. 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"'
  62. );
  63. $form->addElement('html', '<div id="options_field" style="display:none">');
  64. }
  65. GradebookUtils::load_gradebook_select_in_tool($form);
  66. $form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook'));
  67. $form->applyFilter('attendance_qualify_title', 'html_filter');
  68. $form->addElement(
  69. 'text',
  70. 'attendance_weight',
  71. get_lang('QualifyWeight'),
  72. 'value="0.00" Style="width:40px" onfocus="javascript: this.select();"'
  73. );
  74. $form->applyFilter('attendance_weight', 'html_filter');
  75. $form->addElement('html', '</div>');
  76. $form->addElement('html', '</div>');
  77. }
  78. $form->addButtonUpdate(get_lang('Save'));
  79. // set default values
  80. $default['title'] = Security::remove_XSS($title);
  81. $default['description'] = Security::remove_XSS($description, STUDENT);
  82. $default['attendance_qualify_title'] = $attendance_qualify_title;
  83. $default['attendance_weight'] = $attendance_weight;
  84. $link_info = GradebookUtils::isResourceInCourseGradebook(
  85. api_get_course_id(),
  86. 7,
  87. $attendance_id,
  88. api_get_session_id()
  89. );
  90. $default['category_id'] = $link_info['category_id'];
  91. $form->setDefaults($default);
  92. $form->display();