public function test_facetoface_get_status()
 {
     // Check for valid status codes.
     $this->assertEqual(facetoface_get_status(10), 'user_cancelled');
     // SESSION_CANCELLED is not yet implemented.
     // $this->assertEqual(facetoface_get_status(20), 'session_cancelled');
     $this->assertEqual(facetoface_get_status(30), 'declined');
     $this->assertEqual(facetoface_get_status(40), 'requested');
     $this->assertEqual(facetoface_get_status(50), 'approved');
     $this->assertEqual(facetoface_get_status(60), 'waitlisted');
     $this->assertEqual(facetoface_get_status(70), 'booked');
     $this->assertEqual(facetoface_get_status(80), 'no_show');
     $this->assertEqual(facetoface_get_status(90), 'partially_attended');
     $this->assertEqual(facetoface_get_status(100), 'fully_attended');
     // TODO error capture.
     // Check for invalid status code.
     // $this->expectError(facetoface_get_status(17));
     // $this->expectError(facetoface_get_status('b'));
     // $this->expectError(facetoface_get_status('%'));
 }
Beispiel #2
0
$cell = new html_table_cell($content);
$cell->attributes['id'] = 'backcell';
$cell->attributes['colspan'] = '3';
$table->data[] = new html_table_row(array($cell));
$out .= html_writer::table($table);
// Get all signed up non-attendees.
$nonattendees = 0;
$usernamefields = get_all_user_name_fields(true, 'u');
$nonattendeesrs = $DB->get_recordset_sql("SELECT\n            u.id,\n            {$usernamefields},\n            u.email,\n            ss.statuscode\n        FROM\n            {facetoface_sessions} s\n        JOIN\n            {facetoface_signups} su\n         ON s.id = su.sessionid\n        JOIN\n            {facetoface_signups_status} ss\n         ON su.id = ss.signupid\n        JOIN\n            {user} u\n         ON u.id = su.userid\n        WHERE\n            s.id = ?\n        AND ss.superceded != 1\n        AND ss.statuscode = ?\n        ORDER BY\n            u.lastname, u.firstname", array($session->id, MDL_F2F_STATUS_REQUESTED));
$table = new html_table();
$table->head = array(get_string('name'), get_string('email'), get_string('status'));
foreach ($nonattendeesrs as $user) {
    $data = array();
    $data[] = new html_table_cell(fullname($user));
    $data[] = new html_table_cell($user->email);
    $data[] = new html_table_cell(get_string('status_' . facetoface_get_status($user->statuscode), 'facetoface'));
    $row = new html_table_row($data);
    $table->data[] = $row;
    $nonattendees++;
}
$nonattendeesrs->close();
if ($nonattendees) {
    $out .= html_writer::empty_tag('br');
    $out .= $OUTPUT->heading(get_string('unapprovedrequests', 'facetoface') . ' (' . $nonattendees . ')');
    $out .= html_writer::table($table);
}
$out .= html_writer::end_tag('div') . html_writer::end_tag('form');
echo $out;
if (!empty($errors)) {
    $msg = html_writer::start_tag('p');
    foreach ($errors as $e) {
Beispiel #3
0
 /**
  * Builds session list table given an array of sessions
  */
 public function print_session_list_table($customfields, $sessions, $viewattendees, $editsessions)
 {
     global $CFG;
     $output = '';
     $tableheader = array();
     foreach ($customfields as $field) {
         if (!empty($field->showinsummary)) {
             $tableheader[] = format_string($field->name);
         }
     }
     $tableheader[] = get_string('date', 'facetoface');
     $tableheader[] = get_string('time', 'facetoface');
     if ($viewattendees) {
         $tableheader[] = get_string('capacity', 'facetoface');
     } else {
         $tableheader[] = get_string('seatsavailable', 'facetoface');
     }
     $tableheader[] = get_string('status', 'facetoface');
     $tableheader[] = get_string('options', 'facetoface');
     $timenow = time();
     $table = new html_table();
     $table->summary = get_string('previoussessionslist', 'facetoface');
     $table->head = $tableheader;
     $table->data = array();
     foreach ($sessions as $session) {
         $isbookedsession = false;
         $bookedsession = $session->bookedsession;
         $sessionstarted = false;
         $sessionfull = false;
         $sessionrow = array();
         // Custom fields.
         $customdata = $session->customfielddata;
         foreach ($customfields as $field) {
             if (empty($field->showinsummary)) {
                 continue;
             }
             if (empty($customdata[$field->id])) {
                 $sessionrow[] = ' ';
             } else {
                 if (CUSTOMFIELD_TYPE_MULTISELECT == $field->type) {
                     $sessionrow[] = str_replace(CUSTOMFIELD_DELIMITER, html_writer::empty_tag('br'), format_string($customdata[$field->id]->data));
                 } else {
                     $sessionrow[] = format_string($customdata[$field->id]->data);
                 }
             }
         }
         // Dates/times.
         $allsessiondates = '';
         $allsessiontimes = '';
         if ($session->datetimeknown) {
             foreach ($session->sessiondates as $date) {
                 if (!empty($allsessiondates)) {
                     $allsessiondates .= html_writer::empty_tag('br');
                 }
                 $allsessiondates .= userdate($date->timestart, get_string('strftimedate'));
                 if (!empty($allsessiontimes)) {
                     $allsessiontimes .= html_writer::empty_tag('br');
                 }
                 $allsessiontimes .= userdate($date->timestart, get_string('strftimetime')) . ' - ' . userdate($date->timefinish, get_string('strftimetime'));
             }
         } else {
             $allsessiondates = get_string('wait-listed', 'facetoface');
             $allsessiontimes = get_string('wait-listed', 'facetoface');
             $sessionwaitlisted = true;
         }
         $sessionrow[] = $allsessiondates;
         $sessionrow[] = $allsessiontimes;
         // Capacity.
         $signupcount = facetoface_get_num_attendees($session->id, MDL_F2F_STATUS_APPROVED);
         $stats = $session->capacity - $signupcount;
         if ($viewattendees) {
             $stats = $signupcount . ' / ' . $session->capacity;
         } else {
             $stats = max(0, $stats);
         }
         $sessionrow[] = $stats;
         // Status.
         $status = get_string('bookingopen', 'facetoface');
         if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) {
             $status = get_string('sessioninprogress', 'facetoface');
             $sessionstarted = true;
         } else {
             if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) {
                 $status = get_string('sessionover', 'facetoface');
                 $sessionstarted = true;
             } else {
                 if ($bookedsession && $session->id == $bookedsession->sessionid) {
                     $signupstatus = facetoface_get_status($bookedsession->statuscode);
                     $status = get_string('status_' . $signupstatus, 'facetoface');
                     $isbookedsession = true;
                 } else {
                     if ($signupcount >= $session->capacity) {
                         $status = get_string('bookingfull', 'facetoface');
                         $sessionfull = true;
                     }
                 }
             }
         }
         $sessionrow[] = $status;
         // Options.
         $options = '';
         if ($editsessions) {
             $options .= $this->output->action_icon(new moodle_url($CFG->wwwroot . '/mod/facetoface/' . 'sessions.php', array('s' => $session->id)), new pix_icon('t/edit', get_string('edit', 'facetoface')), null, array('title' => get_string('editsession', 'facetoface'))) . ' ';
             $options .= $this->output->action_icon(new moodle_url($CFG->wwwroot . '/mod/facetoface/' . 'sessions.php', array('s' => $session->id, 'c' => 1)), new pix_icon('t/copy', get_string('copy', 'facetoface')), null, array('title' => get_string('copysession', 'facetoface'))) . ' ';
             $options .= $this->output->action_icon(new moodle_url($CFG->wwwroot . '/mod/facetoface/' . 'sessions.php', array('s' => $session->id, 'd' => 1)), new pix_icon('t/delete', get_string('delete', 'facetoface')), null, array('title' => get_string('deletesession', 'facetoface'))) . ' ';
             $options .= html_writer::empty_tag('br');
         }
         if ($viewattendees) {
             $options .= html_writer::link($CFG->wwwroot . '/mod/facetoface/' . 'attendees.php?s=' . $session->id . '&backtoallsessions=' . $session->facetoface, get_string('attendees', 'facetoface'), array('title' => get_string('seeattendees', 'facetoface'))) . html_writer::empty_tag('br');
         }
         if ($isbookedsession) {
             $options .= html_writer::link($CFG->wwwroot . '/mod/facetoface/' . 'signup.php?s=' . $session->id . '&backtoallsessions=' . $session->facetoface, get_string('moreinfo', 'facetoface'), array('title' => get_string('moreinfo', 'facetoface'))) . html_writer::empty_tag('br');
             $options .= html_writer::link($CFG->wwwroot . '/mod/facetoface/' . 'cancelsignup.php?s=' . $session->id . '&backtoallsessions=' . $session->facetoface, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface')));
         } else {
             if (!$sessionstarted and !$bookedsession) {
                 $options .= html_writer::link($CFG->wwwroot . '/mod/facetoface/' . 'signup.php?s=' . $session->id . '&backtoallsessions=' . $session->facetoface, get_string('signup', 'facetoface'));
             }
         }
         if (empty($options)) {
             $options = get_string('none', 'facetoface');
         }
         $sessionrow[] = $options;
         $row = new html_table_row($sessionrow);
         // Set the CSS class for the row.
         if ($sessionstarted) {
             $row->attributes = array('class' => 'dimmed_text');
         } else {
             if ($isbookedsession) {
                 $row->attributes = array('class' => 'highlight');
             } else {
                 if ($sessionfull) {
                     $row->attributes = array('class' => 'dimmed_text');
                 }
             }
         }
         // Add row to table.
         $table->data[] = $row;
     }
     $output .= html_writer::table($table);
     return $output;
 }
$cm = get_coursemodule_from_instance('facetoface', $facetoface->id, $course->id);
$contextmodule = context_module::instance($cm->id);
$viewattendees = has_capability('mod/facetoface:viewattendees', $contextmodule);
echo facetoface_print_session($session, $viewattendees, false, false, true);

// print the booking history
if ($bookings and count($bookings) > 0) {

    $table = new html_table();
    $table->summary = get_string('sessionsdetailstablesummary', 'facetoface');
    $table->attributes['class'] = 'generaltable bookinghistory';

    foreach ($bookings as $booking) {

        $row = array(
            get_string('status_'.facetoface_get_status($booking->statuscode), 'facetoface'),
            userdate($booking->timecreated, get_string('strftimedatetime'))
        );

        if (strlen(trim($booking->note))) {
            $row[] = $booking->note;
        }

        $table->data[] = $row;
    }

} else {
    // no booking history available
    $table = new html_table();
    $table->summary = get_string('sessionsdetailstablesummary', 'facetoface');
    $table->attributes['class'] = 'generaltable bookinghistory';
    /**
     * Builds session list table given an array of sessions
     */
    public function print_session_list_table($customfields, $sessions, $viewattendees, $editsessions) {
        $output = '';

        $tableheader = array();
        foreach ($customfields as $field) {
            if (!empty($field->showinsummary)) {
                $tableheader[] = format_string($field->name);
            }
        }
        $tableheader[] = get_string('date', 'facetoface');
        $tableheader[] = get_string('time', 'facetoface');
        $tableheader[] = get_string('room', 'facetoface');
        if ($viewattendees) {
            $tableheader[] = get_string('capacity', 'facetoface');
        } else {
            $tableheader[] = get_string('seatsavailable', 'facetoface');
        }
        $tableheader[] = get_string('status', 'facetoface');
        $tableheader[] = get_string('options', 'facetoface');

        $timenow = time();

        $table = new html_table();
        $table->summary = get_string('previoussessionslist', 'facetoface');
        $table->attributes['class'] = 'generaltable fullwidth';
        $table->head = $tableheader;
        $table->data = array();

        foreach ($sessions as $session) {

            $isbookedsession = false;
            $bookedsession = $session->bookedsession;
            $sessionstarted = false;
            $sessionfull = false;

            $sessionrow = array();

            // Custom fields
            $customdata = $session->customfielddata;
            foreach ($customfields as $field) {
                if (empty($field->showinsummary)) {
                    continue;
                }

                if (empty($customdata[$field->id])) {
                    $sessionrow[] = ' ';
                } else {
                    if (CUSTOMFIELD_TYPE_MULTISELECT == $field->type) {
                        $sessionrow[] = str_replace(CUSTOMFIELD_DELIMITER, html_writer::empty_tag('br'), format_string($customdata[$field->id]->data));
                    } else {
                        $sessionrow[] = format_string($customdata[$field->id]->data);
                    }
                }
            }

            // Dates/times
            $allsessiondates = '';
            $allsessiontimes = '';
            if ($session->datetimeknown) {
                foreach ($session->sessiondates as $date) {
                    if (!empty($allsessiondates)) {
                        $allsessiondates .= html_writer::empty_tag('br');
                        $allsessiontimes .= html_writer::empty_tag('br');
                    }
                    $sessionobj = facetoface_format_session_times($date->timestart, $date->timefinish, $date->sessiontimezone);
                    if ($sessionobj->startdate == $sessionobj->enddate) {
                        $allsessiondates .= $sessionobj->startdate;
                    } else {
                        $allsessiondates .= $sessionobj->startdate . ' - ' . $sessionobj->enddate;
                    }
                    $allsessiontimes .= $sessionobj->starttime . ' - ' . $sessionobj->endtime . ' ' . $sessionobj->timezone;
                }
            } else {
                $allsessiondates = get_string('wait-listed', 'facetoface');
                $allsessiontimes = get_string('wait-listed', 'facetoface');
                $sessionwaitlisted = true;
            }
            $sessionrow[] = $allsessiondates;
            $sessionrow[] = $allsessiontimes;

            // Room.
            if (isset($session->room)) {
                $roomhtml = '';
                $roomhtml .= isset($session->room->name) ? format_string($session->room->name) . html_writer::empty_tag('br') : '';
                $roomhtml .= isset($session->room->building) ? format_string($session->room->building) . html_writer::empty_tag('br') : '';
                $roomhtml .= isset($session->room->address) ? format_string($session->room->address) . html_writer::empty_tag('br') : '';
                $sessionrow[] = $roomhtml;
            } else {
                $sessionrow[] = '';
            }

            // Capacity.
            if ($session->datetimeknown) {
                $signupcount = facetoface_get_num_attendees($session->id, MDL_F2F_STATUS_BOOKED);
            } else {
                $signupcount = facetoface_get_num_attendees($session->id, MDL_F2F_STATUS_APPROVED);
            }
            if ($viewattendees) {
                if ($session->datetimeknown) {
                    $a = array('current' => $signupcount, 'maximum' => $session->capacity);
                    $stats = get_string('capacitycurrentofmaximum', 'facetoface', $a);
                    if ($signupcount > $session->capacity) {
                        $stats .= get_string('capacityoverbooked', 'facetoface');
                    }
                    $waitlisted = facetoface_get_num_attendees($session->id, MDL_F2F_STATUS_APPROVED) - $signupcount;
                    if ($waitlisted > 0) {
                        $stats .= " (" . $waitlisted . " " . get_string('status_waitlisted', 'facetoface') . ")";
                    }
                } else {
                    $stats = $session->capacity . " (" . $signupcount . " " . get_string('status_waitlisted', 'facetoface') . ")";
                }
            } else {
                $stats = max(0, $session->capacity - $signupcount);
            }
            $sessionrow[] = $stats;

            // Status.
            $allowcancellation = false;
            $status  = get_string('bookingopen', 'facetoface');
            if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) {
                $status = get_string('sessioninprogress', 'facetoface');
                $sessionstarted = true;
                // If user status is wait-listed.
                if ($bookedsession && $bookedsession->statuscode == MDL_F2F_STATUS_WAITLISTED) {
                    $allowcancellation = true;
                }
            } else if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) {
                $status = get_string('sessionover', 'facetoface');
                $sessionstarted = true;
                // If user status is wait-listed.
                if ($bookedsession && $bookedsession->statuscode == MDL_F2F_STATUS_WAITLISTED) {
                    $allowcancellation = true;
                }
            } else if ($bookedsession && $session->id == $bookedsession->sessionid) {
                $signupstatus = facetoface_get_status($bookedsession->statuscode);
                $status = get_string('status_'.$signupstatus, 'facetoface');
                $isbookedsession = true;
            } else if ($signupcount >= $session->capacity) {
                $status = get_string('bookingfull', 'facetoface');
                $sessionfull = true;
            }

            $sessionrow[] = $status;

            // Options.
            $options = '';
            if ($editsessions) {
                $options .= $this->output->action_icon(new moodle_url('sessions.php', array('s' => $session->id)), new pix_icon('t/edit', get_string('edit', 'facetoface')), null, array('title' => get_string('editsession', 'facetoface'))) . ' ';
                $options .= $this->output->action_icon(new moodle_url('sessions.php', array('s' => $session->id, 'c' => 1)), new pix_icon('t/copy', get_string('copy', 'facetoface')), null, array('title' => get_string('copysession', 'facetoface'))) . ' ';
                $options .= $this->output->action_icon(new moodle_url('sessions.php', array('s' => $session->id, 'd' => 1)), new pix_icon('t/delete', get_string('delete', 'facetoface')), null, array('title' => get_string('deletesession', 'facetoface'))) . ' ';
                $options .= html_writer::empty_tag('br');
            }
            if ($viewattendees) {
                $options .= html_writer::link('attendees.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('attendees', 'facetoface'), array('title' => get_string('seeattendees', 'facetoface')));
                $options .= html_writer::empty_tag('br');
            }
            if ($isbookedsession) {
                $options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('moreinfo', 'facetoface'), array('title' => get_string('moreinfo', 'facetoface')));
                $options .= html_writer::empty_tag('br');
                $options .= html_writer::link('cancelsignup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface')));
            } else if (!$sessionstarted and !$bookedsession) {
                if (!facetoface_session_has_capacity($session, $this->context, MDL_F2F_STATUS_WAITLISTED) && !$session->allowoverbook) {
                    $options .= get_string('none', 'facetoface');
                } else {
                    $options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('signup', 'facetoface'));
                }
            }
            if (empty($options)) {
                if ($sessionstarted && $allowcancellation) {
                    $options = html_writer::link('cancelsignup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface')));
                } else {
                    $options = get_string('none', 'facetoface');
                }
            }
            $sessionrow[] = $options;

            $row = new html_table_row($sessionrow);

            // Set the CSS class for the row.
            if ($sessionstarted) {
                $row->attributes = array('class' => 'dimmed_text');
            } else if ($isbookedsession) {
                $row->attributes = array('class' => 'highlight');
            } else if ($sessionfull) {
                $row->attributes = array('class' => 'dimmed_text');
            }

            // Add row to table.
            $table->data[] = $row;
        }

        $output .= html_writer::table($table);

        return $output;
    }
             $optionid = 'submissionid_'.$attendee->submissionid;
             $status = $attendee->statuscode;
             $select = html_writer::select($status_options, $optionid, $status);
             $data[] = $select;
         }
     } else if ($action == 'cancellations') {
         $data[] = userdate($attendee->timecancelled, get_string('strftimedatetime'));
         $data[] = isset($attendee->cancelreason) ? format_string($attendee->cancelreason) : get_string('none');
     } else {
         if (!get_config(NULL, 'facetoface_hidecost')) {
             $data[] = facetoface_cost($attendee->id, $session->id, $session);
             if (!get_config(NULL, 'facetoface_hidediscount')) {
                 $data[] = $attendee->discountcode;
             }
         }
         $data[] = str_replace(' ', ' ', get_string('status_'.facetoface_get_status($attendee->statuscode), 'facetoface'));
     }
     if (!$download) {
         $table->add_data($data);
     } else {
         $export_rows[] = $data;
     }
 }
 if (!$download) {
     $table->finish_output();
 } else {
     switch ($download) {
         case 'ods':
             facetoface_download_ods($headers, $export_rows, $exportfilename);
             break;
         case 'xls':
    function definition() {
        global $CFG;

        $mform =& $this->_form;

        $mform->addElement('hidden', 's', $this->_customdata['s']);
        $mform->setType('s', PARAM_INT);

        $mform->addElement('header', 'recipientgroupsheader', get_string('messagerecipientgroups', 'facetoface'));

        // Display select recipient by status
        $statuses = array(
            MDL_F2F_STATUS_USER_CANCELLED,
            MDL_F2F_STATUS_WAITLISTED,
            MDL_F2F_STATUS_BOOKED,
            MDL_F2F_STATUS_NO_SHOW,
            MDL_F2F_STATUS_PARTIALLY_ATTENDED,
            MDL_F2F_STATUS_FULLY_ATTENDED
        );

        $json_users = array();
        $attendees = array();
        foreach ($statuses as $status) {
            // Get count of users with this status
            $count = facetoface_get_num_attendees($this->_customdata['s'], $status, '=');

            if (!$count) {
                continue;
            }

            $users = facetoface_get_users_by_status($this->_customdata['s'], $status);
            $json_users[$status] = $users;
            $attendees = array_merge($attendees, $users);

            $title = facetoface_get_status($status);

            $mform->addElement('checkbox', 'recipient_group['.$status.']', get_string('status_'.$title, 'facetoface') . ' - ' . get_string('xusers', 'facetoface', $count));
        }

        // Display individual recipient selectors
        $mform->addElement('header', 'recipientsheader', get_string('messagerecipients', 'facetoface'));

        $options = array();
        foreach ($attendees as $a) {
            $options[$a->id] = fullname($a);
        }
        $mform->addElement('select', 'recipients', get_string('individuals', 'facetoface'), $options,  array('size' => 5));
        $mform->addElement('hidden', 'recipients_selected');
        $mform->setType('recipients_selected', PARAM_SEQUENCE);
        $mform->addElement('button', 'recipient_custom', get_string('editmessagerecipientsindividually', 'facetoface'));
        $mform->addElement('checkbox', 'cc_managers', get_string('messagecc', 'facetoface'));

        $mform->addElement('header', 'messageheader', get_string('messageheader', 'facetoface'));

        $mform->addElement('text', 'subject', get_string('messagesubject', 'facetoface'));
        $mform->setType('subject', PARAM_TEXT);
        $mform->addRule('subject', get_string('required'), 'required', null, 'client');

        $mform->addElement('editor', 'body', get_string('messagebody', 'facetoface'));
        $mform->setType('body', PARAM_CLEANHTML);
        $mform->addRule('body', get_string('required'), 'required', null, 'client');

        $json_users = json_encode($json_users);
        $mform->addElement('html', '<script type="text/javascript">var recipient_groups = '.$json_users.'</script>');

        // Add action buttons
        $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('sendmessage', 'facetoface'));
        $buttonarray[] = $mform->createElement('cancel', 'cancel', get_string('discardmessage', 'facetoface'));

        $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
        $mform->closeHeaderBefore('buttonar');
    }
    function rb_display_facetoface_status($status, $row) {
        global $CFG, $MDL_F2F_STATUS;

        include_once($CFG->dirroot.'/mod/facetoface/lib.php');

        // if status doesn't exist just return the status code
        if (!isset($MDL_F2F_STATUS[$status])) {
            return $status;
        }
        // otherwise return the string
        return get_string('status_'.facetoface_get_status($status),'facetoface');
    }
    function test_facetoface_get_status() {
        // check for valid status codes
        $this->assertEquals(facetoface_get_status(10), 'user_cancelled');
        //$this->assertEquals(facetoface_get_status(20), 'session_cancelled'); //not yet implemented
        $this->assertEquals(facetoface_get_status(30), 'declined');
        $this->assertEquals(facetoface_get_status(40), 'requested');
        $this->assertEquals(facetoface_get_status(50), 'approved');
        $this->assertEquals(facetoface_get_status(60), 'waitlisted');
        $this->assertEquals(facetoface_get_status(70), 'booked');
        $this->assertEquals(facetoface_get_status(80), 'no_show');
        $this->assertEquals(facetoface_get_status(90), 'partially_attended');
        $this->assertEquals(facetoface_get_status(100), 'fully_attended');

        $this->resetAfterTest(true);
    }
Beispiel #10
0
    public function print_dates($dates, $includebookings, $includegrades=false, $includestatus=false, $includecourseid=false, $includetrainers=false, $showlocation=true) {
        global $CFG, $USER;

        $output = '';

        $courselink = $CFG->wwwroot.'/course/view.php?id=';
        $facetofacelink = $CFG->wwwroot.'/mod/facetoface/view.php?f=';
        $attendeelink = $CFG->wwwroot.'/mod/facetoface/attendees.php?s=';
        $bookinghistoryurl = new moodle_url('/blocks/facetoface/bookinghistory.php');

        $output .= html_writer::start_tag('table', array('border' => "1", 'cellpadding' => "5", 'summary' => get_string('sessiondatestable', 'block_facetoface'))) . html_writer::start_tag('tr');

        // include the course id in the display
        if ($includecourseid) {
            $output .= html_writer::tag('th', get_string('idnumbercourse'));
        }

        $output .= html_writer::tag('th', get_string('course'));
        $output .= html_writer::tag('th', get_string('name'));
        if ($showlocation) {
            $output .= html_writer::tag('th', get_string('location'));
        }
        $output .= html_writer::tag('th', get_string('date','block_facetoface'));
        $output .= html_writer::tag('th', get_string('time', 'block_facetoface'));

        if ($includebookings) {
            $output .= html_writer::tag('th', get_string('nbbookings', 'block_facetoface'));
        }

        // include the grades/status in the display
        if ($includegrades || $includestatus) {
            $output .= html_writer::tag('th', get_string('status'));
        }

        $output .= html_writer::end_tag('tr');
        $even = false; // used to colour rows
        foreach ($dates as $date) {

            // include the grades in the display
            if ($includegrades) {
                $grade = facetoface_get_grade($date->userid, $date->courseid, $date->facetofaceid);
            }

            if ($even) {
                $output .= html_writer::start_tag('tr', array('style' => 'background-color: #CCCCCC', 'valign' => 'top'));
            }
            else {
                $output .= html_writer::start_tag('tr', array('valign' => 'top'));
            }
            $even = !$even;
            if ($includecourseid) {
                $output .= html_writer::tag('td', $date->cidnumber);
            }
            $output .= html_writer::tag('td', html_writer::link($courselink.$date->courseid, format_string($date->coursename)));

            $output .= html_writer::tag('td', html_writer::link($facetofacelink.$date->facetofaceid, format_string($date->name)));
            if ($showlocation) {
                $location = isset($date->location) ? $date->location : '';
                $output .= html_writer::tag('td', format_string($location));
            }

            $output .= html_writer::start_tag('td');
            if ($date->datetimeknown) {
                $sessiondates = $date->alldates;
                foreach ($sessiondates as $sessiondate) {
                    $sessionobj = facetoface_format_session_times($sessiondate->timestart, $sessiondate->timefinish, $sessiondate->sessiontimezone);
                    if ($sessionobj->startdate == $sessionobj->enddate) {
                        $output .= $sessionobj->startdate . html_writer::empty_tag('br');
                    } else {
                        $output .= $sessionobj->startdate . ' - ' . $sessionobj->enddate . html_writer::empty_tag('br');
                    }
                }
                $output .= html_writer::end_tag('td');
                $output .= html_writer::start_tag('td');
                foreach ($sessiondates as $sessiondate) {
                    $sessionobj = facetoface_format_session_times($sessiondate->timestart, $sessiondate->timefinish, $sessiondate->sessiontimezone);
                    $output .= $sessionobj->starttime . ' - ' . $sessionobj->endtime . ' ' . $sessionobj->timezone . html_writer::empty_tag('br');
                }
            } else {
                $output .= get_string('datenotset', 'block_facetoface');
                $output .= html_writer::end_tag('td');
                $output .= html_writer::start_tag('td');
            }
            $output .= html_writer::end_tag('td');

            if ($includebookings) {
                $output .= html_writer::tag('td', html_writer::link($attendeelink.$date->sessionid, (isset($date->nbbookings)? format_string($date->nbbookings) : 0)));
            }

            // include the grades/status in the display
            foreach (array($includegrades, $includestatus) as $col) {
                if ($col) {
                    $bookinghistoryurl->params(array('session' => $date->sessionid, 'userid' => $date->userid));
                    $output .= html_writer::tag('td', html_writer::link($bookinghistoryurl, get_string('status:' . facetoface_get_status($date->status), 'block_facetoface')));
                }
            }

            $output .= html_writer::end_tag('tr');
        }
        $output .= html_writer::end_tag('table');

        return $output;
    }