Merge pull request #83 from barrysspace/expired_self_enrolments_MDL26
[moodle-mod_attendance.git] / duration_form.php
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17 /**
18 * This file contains the forms for duration
19 *
20 * @package mod_attendance
21 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25 require_once($CFG->libdir.'/formslib.php');
26
27 /**
28 * class for displaying duration form.
29 *
30 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 */
33 class mod_attendance_duration_form extends moodleform {
34
35 /**
36 * Called to define this moodle form
37 *
38 * @return void
39 */
40 public function definition() {
41
42 global $CFG;
43 $mform =& $this->_form;
44
45 $course = $this->_customdata['course'];
46 $cm = $this->_customdata['cm'];
47 $modcontext = $this->_customdata['modcontext'];
48 $ids = $this->_customdata['ids'];
49
50 $mform->addElement('header', 'general', get_string('changeduration', 'attendance'));
51 $mform->addElement('static', 'count', get_string('countofselected', 'attendance'), count(explode('_', $ids)));
52
53 for ($i=0; $i<=23; $i++) {
54 $hours[$i] = sprintf("%02d", $i);
55 }
56 for ($i=0; $i<60; $i+=5) {
57 $minutes[$i] = sprintf("%02d", $i);
58 }
59 $durselect[] =& $mform->createElement('select', 'hours', '', $hours);
60 $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true);
61 $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attendance'), array(' '), true);
62
63 $mform->addElement('hidden', 'ids', $ids);
64 $mform->addElement('hidden', 'id', $cm->id);
65 $mform->addElement('hidden', 'action', att_sessions_page_params::ACTION_CHANGE_DURATION);
66
67 $mform->setDefaults(array('durtime' => array('hours'=>0, 'minutes'=>0)));
68
69 $submit_string = get_string('update', 'attendance');
70 $this->add_action_buttons(true, $submit_string);
71 }
72
73 }