In my very simple new activity
module
in Moodle
I need to add filter
and search
options for the table
with users and the columns with user data.
We have two tabs Userlist
and Add
.
In the first tab we have table, which shows username
timepickedup
timereturn
cartype
city
status
. And lists the userdata bellow these columns.
The code is as follows:
$rows = carhiring_users($cm->id);
foreach ($rows as $carpicker) {
$data = array();
$user = carhiring_get_user($carpicker->userid);
$data[] = $carpicker->cartype;
$data[] = date('d.m.Y H:i', strtotime($carpicker->datepick));
$data[] = date('d.m.Y H:i', strtotime($carpicker->datereturn));
$data[] = $user->firstname . " " . $user->lastname;
$data[] = $carpicker->city;
$datetime1 = strtotime($carpicker->datepick);
$datetime2 = strtotime($carpicker->datereturn);
$interval = $datetime2 - $datetime1;
$data[] = max(1, floor($interval/(60*60*24))) . get_string('carhiring_days', 'carhiring');
switch ($carpicker->carhiring_status) {
case 1:
$carhiring_status = get_string('booked', 'carhiring');
break;
case 2:
$carhiring_status = get_string('bookedbutdamaged', 'carhiring');
break;
case 3:
$carhiring_status = get_string('returned', 'carhiring');
break;
}
$data[] = $carhiring_status;
$table->add_data($data);
}
We add users trough the second tab Add
, where we can choose the user from the users in the Moodle site and manually
add
the rest of custom data
.
I didn't find any search
or filter
forms
for developers in Moodle
. How should such form
be structured in order to work in Moodle
? If it is possible, I need to put it above the table, not in separate tab.