/** * Print the details of a session * * @param object $session Record from facetoface_sessions * @param boolean $showcapacity Show the capacity (true) or only the seats available (false) * @param boolean $calendaroutput Whether the output should be formatted for a calendar event * @param boolean $return Whether to return (true) the html or print it directly (true) * @param boolean $hidesignup Hide any messages relating to signing up */ function facetoface_print_session($session, $showcapacity, $calendaroutput=false, $return=false, $hidesignup=false) { global $CFG, $DB; $table = new html_table(); $table->summary = get_string('sessionsdetailstablesummary', 'facetoface'); $table->attributes['class'] = 'generaltable f2fsession'; $table->align = array('right', 'left'); if ($calendaroutput) { $table->tablealign = 'left'; } $customfields = facetoface_get_session_customfields(); $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); foreach ($customfields as $field) { $data = ''; if (!empty($customdata[$field->id])) { if (CUSTOMFIELD_TYPE_MULTISELECT == $field->type) { $values = explode(CUSTOMFIELD_DELIMITER, format_string($customdata[$field->id]->data)); $data = implode(html_writer::empty_tag('br'), $values); } else { $data = format_string($customdata[$field->id]->data); } } $table->data[] = array(str_replace(' ', ' ', format_string($field->name)), $data); } $strdatetime = str_replace(' ', ' ', get_string('sessiondatetime', 'facetoface')); if ($session->datetimeknown) { $html = ''; foreach ($session->sessiondates as $date) { if (!empty($html)) { $html .= html_writer::empty_tag('br'); } $sessionobj = facetoface_format_session_times($date->timestart, $date->timefinish, $date->sessiontimezone); if ($sessionobj->startdate == $sessionobj->enddate) { $html .= $sessionobj->startdate . ', '; } else { $html .= $sessionobj->startdate . ' - ' . $sessionobj->enddate . ', '; } $html .= $sessionobj->starttime . ' - ' . $sessionobj->endtime . ' ' . $sessionobj->timezone; } $table->data[] = array($strdatetime, $html); } else { $table->data[] = array($strdatetime, html_writer::tag('i', get_string('wait-listed', 'facetoface'))); } $signupcount = facetoface_get_num_attendees($session->id); $placesleft = $session->capacity - $signupcount; if ($showcapacity) { if ($session->allowoverbook) { $table->data[] = array(get_string('capacity', 'facetoface'), get_string('capacityallowoverbook', 'facetoface', $session->capacity)); } else { $table->data[] = array(get_string('capacity', 'facetoface'), $session->capacity); } } elseif (!$calendaroutput) { $table->data[] = array(get_string('seatsavailable', 'facetoface'), max(0, $placesleft)); } // Display requires approval notification $facetoface = $DB->get_record('facetoface', array('id' => $session->facetoface)); if ($facetoface->approvalreqd) { $table->data[] = array('', get_string('sessionrequiresmanagerapproval', 'facetoface')); } // Display waitlist notification if (!$hidesignup && $session->allowoverbook && $placesleft < 1) { $table->data[] = array('', get_string('userwillbewaitlisted', 'facetoface')); } if (!empty($session->duration)) { $table->data[] = array(get_string('duration', 'facetoface'), format_duration($session->duration)); } // Display room information $session->room = $DB->get_record('facetoface_room', array('id' => $session->roomid)); if (!empty($session->room)) { $roomstring = ''; $roomstring = isset($session->room->name) ? format_string($session->room->name) . ', '. html_writer::empty_tag('br') : ''; $roomstring .= isset($session->room->building) ? format_string($session->room->building) . ', ' . html_writer::empty_tag('br') : ''; $roomstring .= isset($session->room->address) ? format_string($session->room->address) . html_writer::empty_tag('br') : ''; $systemcontext = context_system::instance(); $editoroptions = array( 'noclean' => false, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'context' => $systemcontext, ); $session->room->descriptionformat = FORMAT_HTML; $session->room = file_prepare_standard_editor($session->room, 'description', $editoroptions, $systemcontext, 'facetoface', 'room', $session->room->id); $roomstring .= $session->room->description_editor['text']; $table->data[] = array(get_string('room', 'facetoface'), $roomstring); } if (!empty($session->normalcost)) { $table->data[] = array(get_string('normalcost', 'facetoface'), format_string($session->normalcost)); } if (!empty($session->discountcost)) { $table->data[] = array(get_string('discountcost', 'facetoface'), format_string($session->discountcost)); } // Display trainers. $courseid = $DB->get_field('facetoface', 'course', array('id' => $session->facetoface)); $coursecontext = context_course::instance($courseid); if (!empty($session->details)) { if ($cm = get_coursemodule_from_instance('facetoface', $facetoface->id, $courseid)) { $context = context_module::instance($cm->id); $session->details = file_rewrite_pluginfile_urls($session->details, 'pluginfile.php', $context->id, 'mod_facetoface', 'session', $session->id); } $details = format_text($session->details, FORMAT_HTML); $table->data[] = array(get_string('details', 'facetoface'), $details); } $trainerroles = facetoface_get_trainer_roles($coursecontext); if ($trainerroles) { // Get trainers. $trainers = facetoface_get_trainers($session->id); foreach ($trainerroles as $role => $rolename) { $rolename = $rolename->localname; if (empty($trainers[$role])) { continue; } $trainer_names = array(); foreach ($trainers[$role] as $trainer) { $trainer_url = new moodle_url('/user/view.php', array('id' => $trainer->id)); $trainer_names[] = html_writer::link($trainer_url, fullname($trainer)); } $table->data[] = array($rolename, implode(', ', $trainer_names)); } } return html_writer::table($table, $return); }
/** * 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; }
/** * Print the details of a session * * @param object $session Record from facetoface_sessions * @param boolean $showcapacity Show the capacity (true) or only the seats available (false) * @param boolean $calendaroutput Whether the output should be formatted for a calendar event * @param boolean $return Whether to return (true) the html or print it directly (true) * @param boolean $hidesignup Hide any messages relating to signing up */ function facetoface_print_session($session, $showcapacity, $calendaroutput = false, $return = false, $hidesignup = false) { global $CFG, $DB; $table = new html_table(); $table->summary = get_string('sessionsdetailstablesummary', 'facetoface'); $table->attributes['class'] = 'generaltable f2fsession'; $table->align = array('right', 'left'); if ($calendaroutput) { $table->tablealign = 'left'; } $customfields = facetoface_get_session_customfields(); $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); foreach ($customfields as $field) { $data = ''; if (!empty($customdata[$field->id])) { if (CUSTOMFIELD_TYPE_MULTISELECT == $field->type) { $values = explode(CUSTOMFIELD_DELIMITER, format_string($customdata[$field->id]->data)); $data = implode(html_writer::empty_tag('br'), $values); } else { $data = format_string($customdata[$field->id]->data); } } $table->data[] = array(str_replace(' ', ' ', format_string($field->name)), $data); } $strdatetime = str_replace(' ', ' ', get_string('sessiondatetime', 'facetoface')); if ($session->datetimeknown) { $html = ''; foreach ($session->sessiondates as $date) { if (!empty($html)) { $html .= html_writer::empty_tag('br'); } $timestart = userdate($date->timestart, get_string('strftimedatetime')); $timefinish = userdate($date->timefinish, get_string('strftimedatetime')); $html .= "{$timestart} – {$timefinish}"; } $table->data[] = array($strdatetime, $html); } else { $table->data[] = array($strdatetime, html_writer::tag('i', get_string('wait-listed', 'facetoface'))); } $signupcount = facetoface_get_num_attendees($session->id); $placesleft = $session->capacity - $signupcount; if ($showcapacity) { if ($session->allowoverbook) { $table->data[] = array(get_string('capacity', 'facetoface'), $session->capacity . ' (' . strtolower(get_string('allowoverbook', 'facetoface')) . ')'); } else { $table->data[] = array(get_string('capacity', 'facetoface'), $session->capacity); } } else { if (!$calendaroutput) { $table->data[] = array(get_string('seatsavailable', 'facetoface'), max(0, $placesleft)); } } // Display requires approval notification. $facetoface = $DB->get_record('facetoface', array('id' => $session->facetoface)); if ($facetoface->approvalreqd) { $table->data[] = array('', get_string('sessionrequiresmanagerapproval', 'facetoface')); } // Display waitlist notification. if (!$hidesignup && $session->allowoverbook && $placesleft < 1) { $table->data[] = array('', get_string('userwillbewaitlisted', 'facetoface')); } if (!empty($session->duration)) { $table->data[] = array(get_string('duration', 'facetoface'), format_duration($session->duration)); } if (!empty($session->normalcost)) { $table->data[] = array(get_string('normalcost', 'facetoface'), format_cost($session->normalcost)); } if (!empty($session->discountcost)) { $table->data[] = array(get_string('discountcost', 'facetoface'), format_cost($session->discountcost)); } if (!empty($session->details)) { $details = clean_text($session->details, FORMAT_HTML); $table->data[] = array(get_string('details', 'facetoface'), $details); } // Display trainers. $trainerroles = facetoface_get_trainer_roles(); if ($trainerroles) { // Get trainers. $trainers = facetoface_get_trainers($session->id); foreach ($trainerroles as $role => $rolename) { $rolename = $rolename->name; if (empty($trainers[$role])) { continue; } $trainernames = array(); foreach ($trainers[$role] as $trainer) { $trainerurl = new moodle_url('/user/view.php', array('id' => $trainer->id)); $trainernames[] = html_writer::link($trainerurl, fullname($trainer)); } $table->data[] = array($rolename, implode(', ', $trainernames)); } } return html_writer::table($table, $return); }
// echo $baseurl; $formurl = clone($baseurl); $formurl->param('action', 'messageusers'); $mform = new mod_facetoface_attendees_message_form($formurl, array('s' => $s)); $mform->display(); } /** * Print unapproved requests (if user able to view) */ if ($action == 'approvalrequired') { echo html_writer::empty_tag('br', array('id' => 'unapproved')); $numattendees = facetoface_get_num_attendees($session->id); $numwaiting = count($requests); $availablespaces = $session->capacity - $numattendees; $allowoverbook = $session->allowoverbook; $canoverbook = has_capability('mod/facetoface:overbook', $contextmodule); // Are there more users waiting than spaces available? // Note this does not apply to people with overbook capability (see facetoface_session_has_capacity). if (!$canoverbook && ($numwaiting > $availablespaces)) { $stringmodifier = ($availablespaces > 0) ? 'over' : 'no'; $stringidentifier = ($allowoverbook) ? "approval{$stringmodifier}capacitywaitlist" : "approval{$stringmodifier}capacity"; $overcapacitymessage = get_string($stringidentifier, 'facetoface', array('waiting' => $numwaiting, 'available' => $availablespaces)); echo $OUTPUT->notification($overcapacitymessage, 'notifynotice'); } // If they cannot overbook and no spaces are available, disable the ability to approve more requests. $approvaldisabled = array(); if (!$canoverbook && ($availablespaces <= 0 && !$allowoverbook)) {
/** * 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; }
print_error('error:unknownbuttonclicked', 'facetoface', $returnurl); } // User can not update Manager's email (depreciated functionality). if (!empty($fromform->manageremail)) { // Logging and events trigger. $params = array('context' => $contextmodule, 'objectid' => $session->id); $event = \mod_facetoface\event\update_manageremail_failed::create($params); $event->add_record_snapshot('facetoface_sessions', $session); $event->add_record_snapshot('facetoface', $facetoface); $event->trigger(); } // Get signup type. if (!$session->datetimeknown) { $statuscode = MDL_F2F_STATUS_WAITLISTED; } else { if (facetoface_get_num_attendees($session->id) < $session->capacity) { // Save available. $statuscode = MDL_F2F_STATUS_BOOKED; } else { $statuscode = MDL_F2F_STATUS_WAITLISTED; } } if (!facetoface_session_has_capacity($session, $context) && !$session->allowoverbook) { print_error('sessionisfull', 'facetoface', $returnurl); } else { if (facetoface_get_user_submissions($facetoface->id, $USER->id)) { print_error('alreadysignedup', 'facetoface', $returnurl); } else { if (facetoface_manager_needed($facetoface) && !facetoface_get_manageremail($USER->id)) { print_error('error:manageremailaddressmissing', 'facetoface', $returnurl); } else {
public function attendence_consolidate($id){ global $DB; $session_single=$DB->get_field('facetoface_sessions','id',array('facetoface'=>$id)); $user_rows = facetoface_get_attendees($session_single, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_NO_SHOW, MDL_F2F_STATUS_PARTIALLY_ATTENDED, MDL_F2F_STATUS_FULLY_ATTENDED)); $data_user=array(); echo "<div class='attandance_fullwidth' style='width:100%;float:left'>"; foreach($user_rows as $user_row){ $list=array(); $list[]=$user_row->firstname; $data_user[]=$list; } // table code $table = new html_table(); $table->head = array('Employee'); $table->data=$data_user; echo '<div class="attendee_name" style="float:left;width:10%">'; echo html_writer::table($table); echo '</div>'; //print_object($rows); //$session_details_news=$DB->get_records_sql("SELECT * FROM {facetoface_sessions} WHERE facetoface=$id"); $location=''; $sessions = facetoface_get_sessions($id, $location); //$session_details=$DB->get_records('facetoface_sessions',array('facetoface'=>$id)); $session_count=1; foreach($sessions as $session_details_new){ $has_attendees = facetoface_get_num_attendees($session_details_new->id); if ($has_attendees && $session_details_new->datetimeknown && facetoface_has_session_started($session_details_new, time())) { $rows = facetoface_get_attendees($session_details_new->id, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_NO_SHOW, MDL_F2F_STATUS_PARTIALLY_ATTENDED, MDL_F2F_STATUS_FULLY_ATTENDED)); //print_object($rows); $data=array(); echo '<div class="indiv-attendance" style="float:left;width:10%">'; echo '<form method="post" action="attendence_consolidated.php" id="formattendence_'.$session_details_new->id.'">'; foreach($rows as $row){ $list=array(); if($row->statuscode==80){ $status='<input type="hidden" value="'.$row->submissionid.'" name="submmisionid[]"><input type="checkbox" name="status_['.$row->submissionid.']" checked="checked">'; } else if($row->statuscode==100){ $status='<input type="hidden" value="'.$row->submissionid.'" name="submmisionid[]"><input type="checkbox" name="status_['.$row->submissionid.']" >'; } else{ $status='<input type="hidden" value="'.$row->submissionid.'" name="submmisionid[]"><input type="checkbox" name="status_['.$row->submissionid.']" >'; } $list[]=$status; //$radio='<input type="text" value="'.$row->submissionid.'" name="submmisionid[]"><input type="radio" name="status[]" >'; $data[]=$list; } // table code $unixtime_to_date = date('d-m-Y', $session_details_new->sessiondates[0]->timestart); $unixtime_to_time = date('h:i:s a', $session_details_new->sessiondates[0]->timestart); /*added by hameed on 22 dec for attandance completed marking*/ $attendance_status = $DB->get_field('facetoface_sessions', 'attendence_status', array('id'=>$session_details_new->id)); if($attendance_status == 1){ $class = 'green'; }else{ $class = 'black'; } $session_name='<span class='.$class.'>Session'.$session_count.'<br>'.$unixtime_to_date.'<br>'.$unixtime_to_time.'</span>'; $table = new html_table(); $table->head = array($session_name); $table->data=$data; echo html_writer::table($table); echo '<input type="hidden" value="'.$session_details_new->id.'" name="session_details">'; echo '<input type="submit" value="Absent">'; echo '</form>'; echo '</div>'; $session_count++; echo html_writer::script(" $('.attendence_button').click(function(){ var data = $('#formattendence_$session_details_new->id').serialize(); //alert(data); $.ajax({ url: 'attendence_submit.php', type: 'POST', data: data, beforeSend: function(){ //alert(data); $('#result').html('Sending....'); }, success: function(data){ alert('Attendence Submitted'); //window.location.reload(); } }); }); "); //print_object($session_details_new->id); } } echo "</div>"; }
global $CGF,$DB; require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); require_once($CFG->dirroot.'/mod/facetoface/lib.php'); $PAGE->requires->jquery(); $PAGE->requires->js('/mod/facetoface/custom.js'); $sessionid = required_param('s', PARAM_INT); $pagetitle = 'Attendence'; $PAGE->set_url('/mod/facetoface/attendence.php', array('s' => $sessionid)); $PAGE->set_pagelayout('admin'); $PAGE->set_title($pagetitle); $PAGE->set_heading('Attendence'); require_login(); $PAGE->set_pagelayout('admin'); echo $OUTPUT->header(); $has_attendees = facetoface_get_num_attendees($sessionid); $customdata = $DB->get_record('facetoface_sessions', array('id' => $sessionid)); $sessiondate = $DB->get_record('facetoface_sessions_dates', array('sessionid' => $sessionid)); $strdatetime = str_replace(' ', ' ', get_string('sessiondatetime', 'facetoface')); $html = ''; if (!empty($html)) { $html .= html_writer::empty_tag('br'); } $sessionobj = facetoface_format_session_times($sessiondate->timestart, $sessiondate->timefinish, $sessiondate->sessiontimezone); if ($sessionobj->startdate == $sessionobj->enddate) { $html .= $sessionobj->startdate . ', '; } else { $html .= $sessionobj->startdate . ' - ' . $sessionobj->enddate . ', ';
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'); }
if (!($course = $DB->get_record('course', array('id' => $facetoface->course)))) { print_error('error:coursemisconfigured', 'facetoface'); } if (!($cm = get_coursemodule_from_instance('facetoface', $facetoface->id, $course->id))) { print_error('error:incorrectcoursemodule', 'facetoface'); } $context = context_module::instance($cm->id); //print_r($cm->id); = 35 require_login(); // Setup urls $baseurl = new moodle_url('/local/preiscrizione/view.php?c_id=' . $c_id); $allowed_actions = array(); $available_actions = array(); $PAGE->set_context($context); // Actions the user can perform $has_attendees = facetoface_get_num_attendees($s); $allowed_actions[] = 'attendees'; $allowed_actions[] = 'waitlist'; $allowed_actions[] = 'addattendees'; $available_actions[] = 'attendees'; if (facetoface_get_users_by_status($s, MDL_F2F_STATUS_WAITLISTED)) { $available_actions[] = 'waitlist'; } /*************************************************************************** * Handle actions */ $heading_message = ''; $params = array('sessionid' => $s); $actions = array(); // Check if any dates are set // Get list of actions
$link = html_writer::link("view.php?f=$facetoface->id", $facetoface->name); } $printsection = ''; if ($facetoface->section !== $currentsection) { if ($facetoface->section) { $printsection = $facetoface->section; } $currentsection = $facetoface->section; } $totalsignupcount = 0; if ($sessions = facetoface_get_sessions($facetoface->id)) { foreach ($sessions as $session) { if (!facetoface_has_session_started($session, $timenow)) { $signupcount = facetoface_get_num_attendees($session->id); $totalsignupcount += $signupcount; } } } $url = new moodle_url('/course/view.php', array('id' => $course->id)); $courselink = html_writer::link($url, $course->shortname, array('title' => $course->shortname)); if ($course->format == 'weeks' or $course->format == 'topics') { if (has_capability('mod/facetoface:viewattendees', $context)) { $table->data[] = array ($courselink, $link, $totalsignupcount); } else { $table->data[] = array ($courselink, $link); } } else {
function test_facetoface_get_num_attendees() { // Test variables. $sessionid1 = 2; $sessionid2 = 42; // Test for valid case. $this->assertEquals(facetoface_get_num_attendees($sessionid1), 3); // Test for invalid case. $this->assertEquals(facetoface_get_num_attendees($sessionid2), 0); $this->resetAfterTest(true); }