bump version.
[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 $mform =& $this->_form;
43
44 $cm = $this->_customdata['cm'];
45 $ids = $this->_customdata['ids'];
46
47 $mform->addElement('header', 'general', get_string('changeduration', 'attendance'));
48 $mform->addElement('static', 'count', get_string('countofselected', 'attendance'), count(explode('_', $ids)));
49
50 for ($i = 0; $i <= 23; $i++) {
51 $hours[$i] = sprintf("%02d", $i);
52 }
53 for ($i = 0; $i < 60; $i += 5) {
54 $minutes[$i] = sprintf("%02d", $i);
55 }
56 $durselect[] =& $mform->createElement('select', 'hours', '', $hours);
57 $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true);
58 $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attendance'), array(' '), true);
59
60 $mform->addElement('hidden', 'ids', $ids);
61 $mform->setType('ids', PARAM_ALPHANUMEXT);
62 $mform->addElement('hidden', 'id', $cm->id);
63 $mform->setType('id', PARAM_INT);
64 $mform->addElement('hidden', 'action', mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION);
65 $mform->setType('action', PARAM_INT);
66
67 $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0)));
68
69 $submitstring = get_string('update', 'attendance');
70 $this->add_action_buttons(true, $submitstring);
71 }
72
73 }