/** * 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); }
/** * 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 $OUTPUT->confirm(get_string('noticedeleteconfirm', 'facetoface', $info), new moodle_url("sitenotice.php", $optionsyes), new moodle_url($returnurl)); echo $OUTPUT->footer(); exit; } else { $transaction = $DB->start_delegated_transaction(); $DB->delete_records('facetoface_notice', array('id' => $id)); $DB->delete_records('facetoface_notice_data', array('noticeid' => $id)); $transaction->allow_commit(); redirect($returnurl); } } $customfields = facetoface_get_session_customfields(); $mform = new mod_facetoface_sitenotice_form(null, compact('id', 'customfields')); if ($mform->is_cancelled()) { redirect($returnurl); } if ($fromform = $mform->get_data()) { // Form submitted if (empty($fromform->submitbutton)) { print_error('error:unknownbuttonclicked', 'facetoface', $returnurl); } $todb = new stdClass();
/** * Subsitute the placeholders in message templates for the actual data * * Expects the following parameters in the $data object: * - datetimeknown * - details * - discountcost * - duration * - normalcost * - sessiondates * * @access public * @param string $msg Email message * @param string $facetofacename F2F name * @param obj $user The subject of the message * @param obj $data Session data * @param int $sessionid Session ID * @return string */ function facetoface_message_substitutions($msg, $coursename, $facetofacename, $user, $data, $sessionid) { global $CFG, $DB; if (empty($msg)) { return ''; } if ($data->datetimeknown) { // Scheduled session $alldates = ''; foreach ($data->sessiondates as $date) { if ($alldates != '') { $alldates .= "\n"; } $startdate = userdate($date->timestart, get_string('strftimedate'), $date->sessiontimezone); $finishdate = userdate($date->timefinish, get_string('strftimedate'), $date->sessiontimezone); if ($startdate == $finishdate) { $alldates .= $startdate . ', '; } else { $alldates .= $startdate . ' - ' . $finishdate . ', '; } $starttime = userdate($date->timestart, get_string('strftimetime'), $date->sessiontimezone); $finishtime = userdate($date->timefinish, get_string('strftimetime'), $date->sessiontimezone); $timestr = $starttime . ' - ' . $finishtime . ' ' . $date->sessiontimezone; $alldates .= $timestr; } $startdate = userdate($data->sessiondates[0]->timestart, get_string('strftimedate'), $date->sessiontimezone); $finishdate = userdate($data->sessiondates[0]->timefinish, get_string('strftimedate'), $date->sessiontimezone); $sessiondate = ($startdate == $finishdate) ? $startdate : $startdate . ' - ' . $finishdate; $starttime = userdate($data->sessiondates[0]->timestart, get_string('strftimetime'), $date->sessiontimezone); $finishtime = userdate($data->sessiondates[0]->timefinish, get_string('strftimetime'), $date->sessiontimezone); } else { // Wait-listed session $startdate = get_string('unknowndate', 'facetoface'); $finishdate = get_string('unknowndate', 'facetoface'); $sessiondate = get_string('unknowndate', 'facetoface'); $alldates = get_string('unknowndate', 'facetoface'); $starttime = get_string('unknowntime', 'facetoface'); $finishtime = get_string('unknowntime', 'facetoface'); } $msg = str_replace(get_string('placeholder:coursename', 'facetoface'), $coursename, $msg); $msg = str_replace(get_string('placeholder:facetofacename', 'facetoface'), $facetofacename, $msg); $msg = str_replace(get_string('placeholder:firstname', 'facetoface'), $user->firstname, $msg); $msg = str_replace(get_string('placeholder:lastname', 'facetoface'), $user->lastname, $msg); $msg = str_replace(get_string('placeholder:cost', 'facetoface'), facetoface_cost($user->id, $sessionid, $data), $msg); $msg = str_replace(get_string('placeholder:alldates', 'facetoface'), $alldates, $msg); $msg = str_replace(get_string('placeholder:sessiondate', 'facetoface'), $sessiondate, $msg); $msg = str_replace(get_string('placeholder:startdate', 'facetoface'), $startdate, $msg); $msg = str_replace(get_string('placeholder:finishdate', 'facetoface'), $finishdate, $msg); $msg = str_replace(get_string('placeholder:starttime', 'facetoface'), $starttime, $msg); $msg = str_replace(get_string('placeholder:finishtime', 'facetoface'), $finishtime, $msg); $msg = str_replace(get_string('placeholder:duration', 'facetoface'), format_duration($data->duration), $msg); // add placeholders that somehow have been forgetten since moodle $roomnull = 'N/A'; // Displayed if empty. // Defaults if values are empty $strlocation = $roomnull; $strvenue = $roomnull; $strroom = $roomnull; if ($room = facetoface_get_session_room($sessionid)) { $strlocation = isset($room->address) ? $room->address : $roomnull; $strvenue = isset($room->building) ? $room->building : $roomnull; $strroom = isset($room->name) ? $room->name : $roomnull; } $msg = str_replace(get_string('placeholder:location', 'facetoface'), $strlocation, $msg); $msg = str_replace(get_string('placeholder:venue', 'facetoface'), $strvenue, $msg); $msg = str_replace(get_string('placeholder:room', 'facetoface'), $strroom, $msg); if (empty($data->details)) { $msg = str_replace(get_string('placeholder:details', 'facetoface'), '', $msg); } else { $msg = str_replace(get_string('placeholder:details', 'facetoface'), html_to_text($data->details), $msg); } // Replace more meta data $attendees_url = new moodle_url('/mod/facetoface/attendees.php', array('s' => $sessionid, 'action' => 'approvalrequired')); $link = html_writer::link($attendees_url, $attendees_url, array('title' => get_string('attendees', 'facetoface'))); $msg = str_replace(get_string('placeholder:attendeeslink', 'facetoface'), $link, $msg); if (strstr($msg, get_string('placeholder:reminderperiod', 'facetoface'))) { // Handle the legacy reminderperiod placeholder. $reminderperiod = $DB->get_field('facetoface_notification', 'MAX(scheduleamount)', array('facetofaceid' => $data->facetoface, 'conditiontype' => MDL_F2F_CONDITION_BEFORE_SESSION, 'scheduleunit' => MDL_F2F_SCHEDULE_UNIT_DAY, 'status' => 1), IGNORE_MULTIPLE); $reminderperiod = empty($reminderperiod) ? 0 : $reminderperiod; $msg = str_replace(get_string('placeholder:reminderperiod', 'facetoface'), $reminderperiod, $msg); } // Custom session fields (they look like "session:shortname" in the templates) $customfields = facetoface_get_session_customfields(); $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $sessionid), '', 'fieldid, data'); foreach ($customfields as $field) { $placeholder = "[session:{$field->shortname}]"; $value = ''; if (!empty($customdata[$field->id])) { if (CUSTOMFIELD_TYPE_MULTISELECT == $field->type) { $value = str_replace(CUSTOMFIELD_DELIMITER, ', ', $customdata[$field->id]->data); } else { $value = $customdata[$field->id]->data; } } $msg = str_replace($placeholder, $value, $msg); } return $msg; }
function print_session_list($courseid, $facetoface, $location) { global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2f_renderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $f2f_renderer->setcontext($context); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; $submissions = facetoface_get_user_submissions($facetoface->id, $USER->id); if (!$facetoface->multiplesessions) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); // print_object($customfields); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_custom_sessions($facetoface->id, $location)) { //print_object($sessions); $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) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; if ($facetoface->multiplesessions) { $submission = facetoface_get_user_submissions($facetoface->id, $USER->id,MDL_F2F_STATUS_REQUESTED, MDL_F2F_STATUS_FULLY_ATTENDED, $session->id); $bookedsession = array_shift($submission); } $sessiondata->bookedsession = $bookedsession; // $sessiondata->name=$session->name; if ($session->roomid) { $room = $DB->get_record('facetoface_room', array('id' => $session->roomid)); $sessiondata->room = $room; //$sessiondata->room = "Nrr"; } // Add custom fields to sessiondata $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted if (!$session->datetimeknown) { $sessionwaitlisted = true; } // Check if session is started if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) { $sessionstarted = true; } elseif ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { $sessionstarted = true; } // Put the row in the right table if ($sessionstarted) { $previousarray[] = $sessiondata; } elseif ($sessionwaitlisted) { $upcomingtbdarray[] = $sessiondata; } else { // Normal scheduled session $upcomingarray[] = $sessiondata; } } } // Upcoming sessions print_object($session); // Upcoming sessions $output=''; echo $OUTPUT->heading(get_string('upcomingsessions', 'facetoface')); if (empty($upcomingarray) && empty($upcomingtbdarray)) { print_string('noupcoming', 'facetoface'); } else { $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); $output = $f2f_renderer->print_session_list_custom_table($table,$tableheader,$session->name,$customfields, $upcomingarray, $viewattendees, $editsessions); } // $output=''; // $ff=$facetoface->id; // Previous sessions if (!empty($previousarray)) { //echo $OUTPUT->heading(get_string('previoussessions', 'facetoface')); $output =$f2f_renderer->print_session_list_custom_table($table,$tableheader,$sessionsname,$customfields, $previousarray, $viewattendees, $editsessions); } // $table = new html_table(); //echo $output; echo $out= html_writer::table($output); }
function print_session_list($courseid, $facetoface, $location,$tab,$userid_url=0) { //print_object($userid_url); global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2f_renderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $f2f_renderer->setcontext($context); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; $submissions = facetoface_get_user_submissions($facetoface->id, $USER->id); if (!$facetoface->multiplesessions) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_sessions($facetoface->id, $location)) { $tableheader = array(); //$tableheader[] = get_string('session_name','facetoface'); if($userid_url==0){ $tableheader[] = get_string('date', 'facetoface'); $tableheader[] = get_string('time', 'facetoface'); $tableheader[] = 'Class type'; $tableheader[] = get_string('room', 'facetoface'); $tableheader[] = get_string('capacity', 'facetoface'); $tableheader[] = get_string('status', 'facetoface'); $tableheader[] = get_string('options', 'facetoface'); } else{ $tableheader[] = get_string('date', 'facetoface'); $tableheader[] = get_string('time', 'facetoface'); $tableheader[] = 'Class type'; $tableheader[] = get_string('room', 'facetoface'); $tableheader[] = 'Trainer'; $tableheader[] = get_string('status', 'facetoface'); } $table = new html_table(); $table->summary = get_string('previoussessionslist', 'facetoface'); $table->attributes['class'] = 'generaltable fullwidth'; $table->id = "psession_$facetoface->id"; $table->head = $tableheader; $table->data = array(); foreach ($sessions as $session) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; if ($facetoface->multiplesessions) { $submission = facetoface_get_user_submissions($facetoface->id, $USER->id, MDL_F2F_STATUS_REQUESTED, MDL_F2F_STATUS_FULLY_ATTENDED, $session->id); $bookedsession = array_shift($submission); } $sessiondata->bookedsession = $bookedsession; if ($session->roomid) { $room = $DB->get_record('facetoface_room', array('id' => $session->roomid)); $sessiondata->room = $room; } // Add custom fields to sessiondata $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted //if (!$session->datetimeknown) { // $sessionwaitlisted = true; //} // //// Check if session is started //if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) { // $sessionstarted = true; //} //elseif ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { // $sessionstarted = true; //} // Put the row in the right table //if ($sessionstarted) { // $previousarray[] = $sessiondata; //} //elseif ($sessionwaitlisted) { // $upcomingtbdarray[] = $sessiondata; //} //else { // Normal scheduled session // $upcomingarray[] = $sessiondata; //} if($sessiondata){ $previousarray[] = $sessiondata; } } } // Upcoming sessions $out=''; $output=''; $out .= '<div id="f2fcontainer'.$facetoface->id.'" class="f2fcontainer"></div>'; //$out .='<ul> // <li><a href="#previous'.$facetoface->id.'">'.get_string('sessions', 'facetoface').'</a></li></ul><div>'; //$out .= '<div id="upcoming'.$facetoface->id.'">'; //if (empty($upcomingarray) && empty($upcomingtbdarray)) { // $out .=get_string('noupcoming', 'facetoface'); //} //else { // $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); // $output_te = $f2f_renderer->print_session_list_custom_table($table,$tableheader,'',$customfields, $upcomingarray, $viewattendees, $editsessions,0,$userid_url=0); // $out .= html_writer::table($output_te); //} //$out .="</div>"; // Previous sessions $out .='<div id="previous'.$facetoface->id.'">'; if (!empty($previousarray)) { $output =$f2f_renderer->print_session_list_custom_table($table,$tableheader,'',$customfields, $previousarray, $viewattendees, $editsessions,1,$userid_url); $out .= '<span class="mb-sessions-wrapper">'.html_writer::table($output).'</span>'; }else{ $out.="<div class='empty_data'>No sessions created.</div>"; } $out .="</div>"; $out .= '</div></div>'; $out .= '<script type="text/javascript">YUI().use("tabview", function(Y) { var tabview = new Y.TabView({ srcNode: "#f2fcontainer'.$facetoface->id.'" }); tabview.render();'; if(isset($tab)&&$tab>0) $out .= 'if(typeof tabview != "undefined") { tabview.selectChild('.$tab.'); }'; $out .='});</script>'; $out .= html_writer::script(' $(document).ready(function() { $("#psession_'.$facetoface->id.'").dataTable({ searching: true, "bStateSave": true, "fnDrawCallback": function(oSettings) { if (oSettings._iDisplayLength > oSettings.fnRecordsDisplay()) { $("#psession_'.$facetoface->id.'_paginate").hide(); $("#psession_'.$facetoface->id.'_length").hide(); } }, "aaSorting": [], "bSort" : false, "lengthMenu": [[5, 10, 25,50,100, -1], [5,10,25, 50,100, "All"]], "aoColumnDefs": [{ \'bSortable\': false, \'aTargets\': [ 0 ] }], "language": { "paginate": { "previous": "<<", "next": ">>" } } }); });'); return $out; }
function print_session_list($courseid, $facetofaceid, $location) { global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2frenderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; if ($submissions = facetoface_get_user_submissions($facetofaceid, $USER->id)) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_sessions($facetofaceid, $location)) { foreach ($sessions as $session) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; $sessiondata->bookedsession = $bookedsession; // Add custom fields to sessiondata. $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted. if (!$session->datetimeknown) { $sessionwaitlisted = true; } // Check if session is started. $sessionstarted = facetoface_has_session_started($session, $timenow); if ($session->datetimeknown && $sessionstarted && facetoface_is_session_in_progress($session, $timenow)) { $sessionstarted = true; } else { if ($session->datetimeknown && $sessionstarted) { $sessionstarted = true; } } // Put the row in the right table. if ($sessionstarted) { $previousarray[] = $sessiondata; } else { if ($sessionwaitlisted) { $upcomingtbdarray[] = $sessiondata; } else { // Normal scheduled session. $upcomingarray[] = $sessiondata; } } } } // Upcoming sessions. echo $OUTPUT->heading(get_string('upcomingsessions', 'facetoface')); if (empty($upcomingarray) && empty($upcomingtbdarray)) { print_string('noupcoming', 'facetoface'); } else { $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); echo $f2frenderer->print_session_list_table($customfields, $upcomingarray, $viewattendees, $editsessions); } if ($editsessions) { $addsessionlink = html_writer::link(new moodle_url('sessions.php', array('f' => $facetofaceid)), get_string('addsession', 'facetoface')); echo html_writer::tag('p', $addsessionlink); } // Previous sessions. if (!empty($previousarray)) { echo $OUTPUT->heading(get_string('previoussessions', 'facetoface')); echo $f2frenderer->print_session_list_table($customfields, $previousarray, $viewattendees, $editsessions); } }
function print_session_list($courseid, $facetoface, $location,$currenttab) { global $CFG, $USER, $DB, $OUTPUT, $PAGE; $f2f_renderer = $PAGE->get_renderer('mod_facetoface'); $timenow = time(); $context = context_course::instance($courseid); $f2f_renderer->setcontext($context); $viewattendees = has_capability('mod/facetoface:viewattendees', $context); $editsessions = has_capability('mod/facetoface:editsessions', $context); $bookedsession = null; $submissions = facetoface_get_user_submissions($facetoface->id, $USER->id); if (!$facetoface->multiplesessions) { $submission = array_shift($submissions); $bookedsession = $submission; } $customfields = facetoface_get_session_customfields(); // print_object($customfields); $upcomingarray = array(); $previousarray = array(); $upcomingtbdarray = array(); if ($sessions = facetoface_get_custom_sessions($facetoface->id, $location)) { //print_object($sessions); $tableheader = array(); $tableheader[] = get_string('session_name','facetoface'); $tableheader[] = get_string('date', 'facetoface'); $tableheader[] = get_string('time', 'facetoface'); $tableheader[] = get_string('room', 'facetoface'); $tableheader[] = get_string('capacity', 'facetoface'); $tableheader[] = get_string('status', 'facetoface'); $tableheader[] = get_string('options', 'facetoface'); $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) { $sessionstarted = false; $sessionfull = false; $sessionwaitlisted = false; $isbookedsession = false; $sessiondata = $session; // $sessiondata->bookedsession = $bookedsession; // $sessiondata->name=$session->name; if ($session->roomid) { $room = $DB->get_record('facetoface_room', array('id' => $session->roomid)); $sessiondata->room = $room; } // Add custom fields to sessiondata $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); $sessiondata->customfielddata = $customdata; // Is session waitlisted if (!$session->datetimeknown) { $sessionwaitlisted = true; } // Check if session is started if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) { $sessionstarted = true; } elseif ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { $sessionstarted = true; } // Put the row in the right table if ($sessionstarted) { $previousarray[] = $sessiondata; } elseif ($sessionwaitlisted) { $upcomingtbdarray[] = $sessiondata; } else { // Normal scheduled session $upcomingarray[] = $sessiondata; } } } // Upcoming sessions //print_object($sessions); // Upcoming sessions $output=''; echo "<h2 class='tmhead2'>".get_string('sessions','facetoface')."</h2>"; echo '<div>'; echo '<a href="'.$CFG->wwwroot.'/course/modedit.php?add=facetoface&type=&course=1§ion=1&return=0" > Add New Session </a>'; echo '</div>'; print_sessiontabs($currenttab); $output=''; if($currenttab=="upcoming") { echo $OUTPUT->heading(get_string('upcomingsessions', 'facetoface')); if (empty($upcomingarray) && empty($upcomingtbdarray)) { print_string('noupcoming', 'facetoface'); } else { $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); $output = $f2f_renderer->print_session_list_custom_table($table,$tableheader,$session->name,$customfields, $upcomingarray, $viewattendees, $editsessions); echo $out= html_writer::table($output); } } else if($currenttab=="previous") { // // $ff=$facetoface->id; // Previous sessions if (!empty($previousarray)) { echo $OUTPUT->heading(get_string('previoussessions', 'facetoface')); $output =$f2f_renderer->print_session_list_custom_table($table,$tableheader,$sessionsname,$customfields, $previousarray, $viewattendees, $editsessions); echo $out= html_writer::table($output); } } // $table = new html_table(); //echo $output; }