forked from marxjohnson/moodle-report_cpd
/
edit_activity_form.php
134 lines (120 loc) · 4.95 KB
/
edit_activity_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
// This file is part of CPD Report for Moodle
//
// CPD Report for Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CPD Report for Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with CPD Report for Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines the CPD Activity form
*
* @package admin-report-cpd
* @copyright 2010 Kineo open Source
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class edit_activity_form extends moodleform {
public function definition() {
$mform =& $this->_form;
$mform->addElement('header', 'addactivity', get_string('addactivity', 'report_cpd'));
$mform->addElement('hidden', 'cpdyearid', $this->_customdata['cpdyearid']);
$mform->addElement('hidden', 'process', '1');
if ($this->_customdata['cpdid']) {
// This updates a CPD Report
$mform->addElement('hidden', 'id', $this->_customdata['cpdid']);
}
$mform->addElement(
'textarea',
'objective',
get_string('objective', 'report_cpd'),
array('rows'=>'2', 'cols'=>'40')
);
$mform->addElement(
'textarea',
'development_need',
get_string('developmentneed', 'report_cpd'),
array('rows'=>'2', 'cols'=>'40')
);
if ($this->_customdata['activity_types']) {
$mform->addElement(
'select',
'activitytypeid',
get_string('activitytype', 'report_cpd'),
$this->_customdata['activity_types']
);
}
$mform->addElement(
'textarea',
'activity',
get_string('activityplanned', 'report_cpd'),
array('rows'=>'2', 'cols'=>'40')
);
// Get CPD start and end years
$startyear = date('Y') - 5;
$endyear = date('Y') + 5;
if ($this->_customdata['cpdyear']) {
$startyear = date('Y', $this->_customdata['cpdyear']->startdate);
$endyear = date('Y', $this->_customdata['cpdyear']->enddate);
}
for ($i=1; $i<=31; $i++) {
$days[$i] = $i;
}
for ($i=1; $i<=12; $i++) {
$months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
}
for ($i=$startyear; $i<=$endyear; $i++) {
$years[$i] = $i;
}
$startdate[] = $mform->createElement('select', 'startdate[d]', '', $days);
$startdate[] = $mform->createElement('select', 'startdate[m]', '', $months);
$startdate[] = $mform->createElement('select', 'startdate[Y]', '', $years);
$mform->addGroup(
$startdate,
'startdate',
get_string('datestart', 'report_cpd'),
array(' '),
false
);
$duedate[] = $mform->createElement('select', 'duedate[d]', '', $days);
$duedate[] = $mform->createElement('select', 'duedate[m]', '', $months);
$duedate[] = $mform->createElement('select', 'duedate[Y]', '', $years);
$mform->addGroup(
$duedate,
'duedate',
get_string('dateend', 'report_cpd'),
array(' '),
false
);
if ($this->_customdata['statuses']) {
$mform->addElement(
'select',
'statusid',
get_string('status', 'report_cpd'),
$this->_customdata['statuses']
);
}
$hours = null;
$minutes = null;
for ($i=1; $i<=20; $i++) {
$hours[$i] = $i;
}
for ($i=15; $i<=45; $i+=15) {
$minutes[$i] = $i;
}
$timetaken[] = $mform->createElement('select', 'timetaken[hours]', '', array('' => '--') + $hours);
$timetaken[] = $mform->createElement('select', 'timetaken[minutes]', '', array('' => '--') + $minutes);
$mform->addGroup($timetaken, 'timetaken', get_string('timetaken', 'report_cpd'), ':', false);
$buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('update'));
$buttonarray[] = $mform->createElement('reset', '', get_string('clear', 'report_cpd'));
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->closeHeaderBefore('buttonar');
//$mform->addRule('objective', 'Please enter an objective.', 'required', null, 'client');
}
}