} } // Process removing user assignments from session. if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { require_capability('mod/facetoface:removeattendees', $context); $userstoremove = $existinguserselector->get_selected_users(); if (!empty($userstoremove)) { foreach ($userstoremove as $removeuser) { if (!($removeuser = clean_param($removeuser->id, PARAM_INT))) { continue; // Invalid userid. } if (facetoface_user_cancel($session, $removeuser, true, $cancelerr)) { // Notify the user of the cancellation if the session hasn't started yet. $timenow = time(); if (!$suppressemail and !facetoface_has_session_started($session, $timenow)) { facetoface_send_cancellation_notice($facetoface, $session, $removeuser); } } else { $errors[] = $cancelerr; $usernamefields = get_all_user_name_fields(true); $erruser = $DB->get_record('user', array('id' => $removeuser), "id, {$usernamefields}"); $errors[] = get_string('error:removeattendee', 'facetoface', fullname($erruser)); } } $potentialuserselector->invalidate_selected_users(); $existinguserselector->invalidate_selected_users(); // Update attendees. facetoface_update_attendees($session); } }
/** * Called when viewing course page. * * @param cm_info $coursemodule */ function facetoface_cm_info_view(cm_info $coursemodule) { global $USER, $DB; if (!($facetoface = $DB->get_record('facetoface', array('id' => $coursemodule->instance)))) { return null; } $coursemodule->set_name($facetoface->name); $contextmodule = context_module::instance($coursemodule->id); if (!has_capability('mod/facetoface:view', $contextmodule)) { return null; // Not allowed to view this activity. } $contextcourse = context_course::instance($coursemodule->course); // Can view attendees. $viewattendees = has_capability('mod/facetoface:viewattendees', $contextcourse); // Can see "view all sessions" link even if activity is hidden/currently unavailable. $iseditor = has_any_capability(array('mod/facetoface:viewattendees', 'mod/facetoface:editsessions', 'mod/facetoface:addattendees', 'mod/facetoface:addattendees', 'mod/facetoface:takeattendance'), $contextcourse); $table = html_writer::start_tag('table', array('class' => 'table90 inlinetable')); $timenow = time(); $strviewallsessions = get_string('viewallsessions', 'facetoface'); $sessions_url = new moodle_url('/mod/facetoface/view.php', array('f' => $facetoface->id)); $htmlviewallsessions = html_writer::link($sessions_url, $strviewallsessions, array('class' => 'f2fsessionlinks f2fviewallsessions', 'title' => $strviewallsessions)); if ($submissions = facetoface_get_user_submissions($facetoface->id, $USER->id)) { // User has signedup for the instance. if (!$facetoface->multiplesessions) { // First submission only. $submissions = array(array_shift($submissions)); } foreach ($submissions as $submission) { if ($session = facetoface_get_session($submission->sessionid)) { $allowcancellation = false; if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) { $status = get_string('sessioninprogress', 'facetoface'); if ($submission->statuscode == MDL_F2F_STATUS_WAITLISTED) { $allowcancellation = true; } } else if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { $status = get_string('sessionover', 'facetoface'); if ($submission->statuscode == MDL_F2F_STATUS_WAITLISTED) { $allowcancellation = true; } } else { $status = get_string('bookingstatus', 'facetoface'); } $sessiondates = ''; if ($session->datetimeknown) { foreach ($session->sessiondates as $date) { if (!empty($sessiondates)) { $sessiondates .= html_writer::empty_tag('br'); } $sessionobj = facetoface_format_session_times($date->timestart, $date->timefinish, $date->sessiontimezone); if ($sessionobj->startdate == $sessionobj->enddate) { $sessiondates .= get_string('sessionstartdateandtime', 'facetoface', $sessionobj); } else { $sessiondates .= get_string('sessionstartfinishdateandtime', 'facetoface', $sessionobj); } } } else { $sessiondates = get_string('wait-listed', 'facetoface'); } $span = html_writer::tag('span', get_string('options', 'facetoface').':', array('class' => 'f2fsessionnotice')); $options = html_writer::tag('tr', html_writer::tag('td', ' ')); // Don't include the link to cancel a session if it has already occurred. $moreinfolink = ''; $cancellink = ''; $strcancelbooking = get_string('cancelbooking', 'facetoface'); $cancel_url = new moodle_url('/mod/facetoface/cancelsignup.php', array('s' => $session->id)); if (!facetoface_has_session_started($session, $timenow)) { $strmoreinfo = get_string('moreinfo', 'facetoface'); $signup_url = new moodle_url('/mod/facetoface/signup.php', array('s' => $session->id)); $moreinfolink = html_writer::tag('tr', html_writer::tag('td', html_writer::link($signup_url, $strmoreinfo, array('class' => 'f2fsessionlinks f2fsessioninfolink', 'title' => $strmoreinfo)))); $cancellink = html_writer::tag('tr', html_writer::tag('td', html_writer::link($cancel_url, $strcancelbooking, array('class' => 'f2fsessionlinks f2fviewallsessions', 'title' => $strcancelbooking)))); $options = html_writer::tag('tr', html_writer::tag('td', $span)); } else { // Session is started. if ($allowcancellation) { $cancellink = html_writer::tag('tr', html_writer::tag('td', html_writer::link($cancel_url, $strcancelbooking, array('class' => 'f2fsessionlinks f2fviewallsessions', 'title' => $strcancelbooking)))); } } // Get room data. $roomtext = ''; $roomdata = $DB->get_record('facetoface_room', array('id' => $session->roomid)); if (!empty($roomdata)) { $roomtext = isset($roomdata->name) ? format_string($roomdata->name) .', '.html_writer::empty_tag('br') : ''; $roomtext .= isset($roomdata->building) ? format_string($roomdata->building).', '.html_writer::empty_tag('br') : ''; $roomtext .= isset($roomdata->address) ? format_string($roomdata->address) .', '.html_writer::empty_tag('br') : ''; } // Don't include the link to view attendees if user is lacking capability. $attendeeslink = ''; if ($viewattendees) { $strseeattendees = get_string('seeattendees', 'facetoface'); $attendees_url = new moodle_url('/mod/facetoface/attendees.php', array('s' => $session->id)); $attendeeslink = html_writer::tag('tr', html_writer::tag('td', html_writer::link($attendees_url, $strseeattendees, array('class' => 'f2fsessionlinks f2fviewattendees', 'title' => $strseeattendees)))); $options = html_writer::tag('tr', html_writer::tag('td', $span)); } $table .= html_writer::start_tag('tr') .html_writer::tag('td', $status, array('class' => 'f2fsessionnotice', 'colspan' => '2')) .html_writer::end_tag('tr') .html_writer::start_tag('tr', array('class' => 'f2fsessioninfo')) .html_writer::tag('td', $roomtext . $sessiondates . html_writer::empty_tag('br'), array('class' => 'f2fwidth')) .html_writer::tag('td', html_writer::start_tag('table')) .$options .$moreinfolink .$attendeeslink .$cancellink .html_writer::end_tag('table') .html_writer::end_tag('td') .html_writer::end_tag('tr'); } } // Add closing "view all sessions" row to table. $table .= html_writer::start_tag('tr') .html_writer::tag('td', $htmlviewallsessions, array('colspan' => '2')) .html_writer::end_tag('tr') .html_writer::end_tag('table'); } else if ($sessions = facetoface_get_sessions($facetoface->id)) { if ($facetoface->display > 0) { $j=1; $sessionsinprogress = array(); $futuresessions = array(); foreach ($sessions as $session) { if (!facetoface_session_has_capacity($session, $contextmodule, MDL_F2F_STATUS_WAITLISTED) && !$session->allowoverbook) { continue; } if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && !facetoface_is_session_in_progress($session, $timenow)) { // Finished session, don't display. continue; } else { $signup = get_string('signup', 'facetoface'); $signup_url = new moodle_url('/mod/facetoface/signup.php', array('s' => $session->id)); $moreinfolink = html_writer::tag('tr', html_writer::tag('td', html_writer::link($signup_url, $signup, array('class' => 'f2fsessionlinks f2fsessioninfolink', 'title' => $signup)))); $span = html_writer::tag('span', get_string('options', 'facetoface').':', array('class' => 'f2fsessionnotice')); $options = html_writer::tag('tr', html_writer::tag('td', $span)); } $multidate = ''; $sessiondate = ''; $sessiontime = ''; if ($session->datetimeknown) { if (empty($session->sessiondates)) { $sessiondate = get_string('unknowndate', 'facetoface'); $sessiontime = get_string('unknowntime', 'facetoface'); } else { $sessionobj = facetoface_format_session_times($session->sessiondates[0]->timestart, $session->sessiondates[0]->timefinish, $session->sessiondates[0]->sessiontimezone); if ($sessionobj->startdate == $sessionobj->enddate) { $sessiondate = get_string('sessionstartdateandtime', 'facetoface', $sessionobj); } else { $sessiondate .= get_string('sessionstartfinishdateandtime', 'facetoface', $sessionobj); } if (count($session->sessiondates) > 1) { $multidate = html_writer::start_tag('br') . get_string('multidate', 'facetoface'); } } } else { $sessiondate = get_string('wait-listed', 'facetoface'); } $locationstring = ''; $roomdata = $DB->get_record('facetoface_room', array('id' => $session->roomid)); if (!empty($roomdata)) { $locationstring = isset($roomdata->name) ? format_string($roomdata->name) .', '.html_writer::empty_tag('br') : ''; $locationstring .= isset($roomdata->building) ? format_string($roomdata->building).', '.html_writer::empty_tag('br') : ''; $locationstring .= isset($roomdata->address) ? format_string($roomdata->address) .', '.html_writer::empty_tag('br') : ''; } $sessionobject = new stdClass(); $sessionobject->location = $locationstring; $sessionobject->date = $sessiondate; $sessionobject->multidate = $multidate; if ($session->datetimeknown && (facetoface_has_session_started($session, $timenow)) && facetoface_is_session_in_progress($session, $timenow)) { $sessionsinprogress[] = $sessionobject; } else { $sessionobject->options = $options; $sessionobject->moreinfolink = $moreinfolink; $futuresessions[] = $sessionobject; } $j++; if ($j > $facetoface->display) { break; } } if (!empty($sessionsinprogress)) { $table .= html_writer::start_tag('tr') . html_writer::tag('td', get_string('sessioninprogress', 'facetoface'), array('class' => 'f2fsessionnotice', 'colspan' => '2')) . html_writer::end_tag('tr'); foreach ($sessionsinprogress as $session) { $table .= html_writer::start_tag('tr') .html_writer::tag('td', html_writer::tag('span', $session->location.$session->date.$session->multidate, array('class' => 'f2fsessiontime')), array('class' => 'f2fwidth')) .html_writer::tag('td', html_writer::start_tag('table')) .html_writer::tag('tr', html_writer::tag('td', ' ')) .html_writer::end_tag('table') .html_writer::end_tag('td') .html_writer::end_tag('tr'); } } if (!empty($futuresessions)) { $table .= html_writer::start_tag('tr') . html_writer::tag('td', get_string('signupforsession', 'facetoface'), array('class' => 'f2fsessionnotice', 'colspan' => '2')) . html_writer::end_tag('tr'); foreach ($futuresessions as $session) { $table .= html_writer::start_tag('tr') .html_writer::tag('td', html_writer::tag('span', $session->location.$session->date.$session->multidate, array('class' => 'f2fsessiontime')), array('class' => 'f2fwidth')) .html_writer::tag('td', html_writer::start_tag('table')) .$session->options .$session->moreinfolink .html_writer::end_tag('table') .html_writer::end_tag('td') .html_writer::end_tag('tr'); } } $table .= html_writer::start_tag('tr') .html_writer::tag('td', ($iseditor || ($coursemodule->visible && $coursemodule->available)) ? $htmlviewallsessions : $strviewallsessions, array('colspan' => '2')) .html_writer::end_tag('tr') .html_writer::end_tag('table'); } else { // Show only name if session display is set to zero. $content = html_writer::tag('span', $htmlviewallsessions, array('class' => 'f2fsessionnotice f2factivityname f2fonepointfive')); $coursemodule->set_content($content); return; } } else if (has_capability('mod/facetoface:viewemptyactivities', $contextmodule)) { $content = html_writer::tag('span', $htmlviewallsessions, array('class' => 'f2fsessionnotice f2factivityname f2fonepointfive')); $coursemodule->set_content($content); return; } else { // Nothing to display to this user. $coursemodule->set_content(''); return; } $coursemodule->set_content($table); }
/** * Used by course/lib.php to display a few sessions besides the * facetoface activity on the course page * * @param object $cm the cm_info object for the F2F instance * @global class $USER used to get the current userid * @global class $CFG used to get the path to the module */ function facetoface_cm_info_view(cm_info $cm) { global $CFG, $USER, $DB, $OUTPUT; $contextmodule = context_module::instance($cm->id); if (!has_capability('mod/facetoface:view', $contextmodule)) { return ''; // Not allowed to view this activity. } $timenow = time(); $facetoface = $DB->get_record('facetoface', array('id' => $cm->instance)); if (!$facetoface) { error_log("mod/facetoface: ask to print coursemodule info for a non-existent activity ({$cm->instance})"); return ''; } // View all sessions link. $htmlviewallsessions = html_writer::link(new moodle_url('/mod/facetoface/view.php', array('f' => $facetoface->id)), get_string('viewallsessions', 'facetoface'), array('class' => 'f2fsessionlinks f2fviewallsessions', 'title' => get_string('viewallsessions', 'facetoface'))); $table = new html_table(); $table->attributes['class'] = 'table90 inlinetable'; $table->data[] = array(html_writer::empty_tag('hr')); if ($submissions = facetoface_get_user_submissions($facetoface->id, $USER->id)) { $submission = array_shift($submissions); // First submission. // User has signedup for the instance. if ($session = facetoface_get_session($submission->sessionid)) { $sessiondate = ''; $sessiontime = ''; if ($session->datetimeknown) { foreach ($session->sessiondates as $date) { if (!empty($sessiondate)) { $sessiondate .= html_writer::empty_tag('br'); } $sessiondate .= userdate($date->timestart, get_string('strftimedate')); if (!empty($sessiontime)) { $sessiontime .= html_writer::empty_tag('br'); } $sessiontime .= userdate($date->timestart, get_string('strftimetime')) . ' - ' . userdate($date->timefinish, get_string('strftimetime')); } } else { $sessiondate = get_string('wait-listed', 'facetoface'); $sessiontime = get_string('wait-listed', 'facetoface'); } $location = ' '; $customfielddata = facetoface_get_customfielddata($session->id); if (!empty($customfielddata['location'])) { $location = ' ' . $customfielddata['location']->data; } $venue = ' '; if (!empty($customfielddata['venue'])) { $venue = ' ' . $customfielddata['venue']->data; } // Don't include the link to view attendees if user is lacking capability. $attendeeslink = ''; if (has_capability('mod/facetoface:viewattendees', context_course::instance($cm->course))) { $strattendees = get_string('seeattendees', 'facetoface'); $attendeesurl = new moodle_url('/mod/facetoface/attendees.php', array('s' => $session->id)); $attendeeslink = ' ' . html_writer::link($attendeesurl, $strattendees, array('class' => 'f2fsessionlinks f2fviewattendees', 'title' => $strattendees)); } // Don't include the link to cancel a session if it has already occurred. $cancellink = ''; if (!facetoface_has_session_started($session, $timenow)) { $strcancel = get_string('cancelbooking', 'facetoface'); $cancelurl = new moodle_url('/mod/facetoface/cancelsignup.php', array('s' => $session->id)); $cancellink = ' ' . html_writer::link($cancelurl, $strcancel, array('class' => 'f2fsessionlinks f2fcancel', 'title' => $strcancel)); } // Add table data. $table->data[] = array(get_string('bookingstatus', 'facetoface') . ': '); $table->data[] = array($location, $venue, $sessiondate, $sessiontime); $table->data[] = array(html_writer::tag('span', get_string('options', 'facetoface') . ': ' . html_writer::link(new moodle_url('/mod/facetoface/signup.php', array('s' => $session->id)), get_string('moreinfo', 'facetoface'), array('class' => 'f2fsessionlinks f2fsessioninfolink', 'title' => get_string('moreinfo', 'facetoface'))) . "{$attendeeslink}{$cancellink}")); $table->data[] = array($htmlviewallsessions); } } else { if ($facetoface->display > 0 && ($sessions = facetoface_get_sessions($facetoface->id))) { $table->data[] = array(get_string('signupforsession', 'facetoface')); $count = 0; foreach ($sessions as $session) { // Don't display past or in-progress sessions. if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) { continue; } // Don't diisplay full sessions. if (!facetoface_session_has_capacity($session, $contextmodule)) { continue; } // Check display count. $count++; if ($count > $facetoface->display) { break; } $multiday = ''; $sessiondate = ''; $sessiontime = ''; if ($session->datetimeknown) { if (empty($session->sessiondates)) { $sessiondate = get_string('unknowndate', 'facetoface'); $sessiontime = get_string('unknowntime', 'facetoface'); } else { $sessiondate = userdate($session->sessiondates[0]->timestart, get_string('strftimedate')); $sessiontime = userdate($session->sessiondates[0]->timestart, get_string('strftimetime')) . ' - ' . userdate($session->sessiondates[0]->timefinish, get_string('strftimetime')); if (count($session->sessiondates) > 1) { $multiday = ' (' . get_string('multiday', 'facetoface') . ')'; } } } else { $sessiondate = get_string('wait-listed', 'facetoface'); } $locationstr = ''; $customfielddata = facetoface_get_customfielddata($session->id); if (!empty($customfielddata['location']) && trim($customfielddata['location']->data) != '') { $locationstr = $customfielddata['location']->data . ', '; } if ($cm->uservisible) { $signupurl = new moodle_url('/mod/facetoface/signup.php', array('s' => $session->id)); $row = array(html_writer::link($signupurl, "{$locationstr} {$sessiondate} {$sessiontime} {$multiday}", array('class' => 'f2fsessiontime'))); } else { $row = array(html_writer::tag('span', "{$locationstr} {$sessiondate} {$sessiontime} {$multiday}", array('class' => 'f2fsessiontime'))); } // Add to table. $table->data[] = $row; } if ($cm->uservisible) { $table->data[] = array($htmlviewallsessions); } else { $table->data[] = array($strviewallsessions); } } else { // Nothing to display to this user. return; } } $cm->set_after_link(html_writer::table($table)); }
function simple_template_for_batches($facetofaceid,$session_cancel=0){ global $DB,$CFG,$USER,$SITE; $sentby_name=fullname($DB->get_record('user',array('id'=>$USER->id))); $sentby_id=$USER->id; $facetoface=$DB->get_record_sql("SELECT * FROM {facetoface} where id=$facetofaceid"); if($session_cancel==0 || $session_cancel==2){ $facetofacesessions=$DB->get_records_sql("SELECT * FROM {facetoface_sessions} fss JOIN {facetoface_sessions_dates} as fsd ON fsd.sessionid=fss.id where facetoface=$facetoface->id"); } //print_object($facetofacesessions); $facetoface_users=$DB->get_records_sql("SELECT * FROM {local_batch_users} where f2fid=$facetoface->id"); $facetoface_course=$DB->get_record_sql("SELECT * FROM {local_batch_courses} where batchid=$facetoface->id"); if((!empty($facetoface)) && (!empty($facetoface_users))){ $mail=new stdClass(); switch($facetoface->active){ case 1: if($session_cancel==0){ $mailsubject=get_string('subject_active', 'facetoface'); }elseif($session_cancel==2){ $mailsubject=get_string('subject_active_session_cancel', 'facetoface'); } $mail->batch_status=get_string('batch_active', 'facetoface'); break; case 8: $mailsubject=get_string('subject_complete', 'facetoface'); $mail->batch_status=get_string('batch_complete', 'facetoface'); break; case 2: $mailsubject=get_string('subject_cancel', 'facetoface'); $mail->batch_status=get_string('batch_cancel', 'facetoface'); break; case 0: $batch_cousre=$DB->get_record('course',array('id'=>$facetoface_course->courseid)); $tataaia = new stdclass(); $tataaia->picture3 = $CFG->wwwroot.'/mod/facetoface/pix/Picture3.png'; $tataaia->picture2 = $CFG->wwwroot.'/mod/facetoface/pix/Picture2.png'; $tataaia->programname = $batch_cousre->fullname; $tataaia->date = date("d M, Y ",$facetoface->startdate); $tataaia->time = date("g:i a",$facetoface->startdate);; $tataaia->venue = 'Thane Training Room'; $tataaia->summary =strip_tags($batch_cousre->summary); $tataaia->summary2 = 'Request you to please discuss with your supervisor, plan your work and make sure that you attend this program'; $tataaia->senderfullname = 'Jagadeep M.P'; $tataaia->designation = 'Manager-Training & Development'; $tataaia->mobileno = '9000 469 5151'; $mailsubject="Batch Start Invitation"; $mail->batch_status=get_string('batch_active', 'facetoface'); } $mail->batch_name=$facetoface->name; $mail->batch_startdate=date("d M, Y ",$facetoface->startdate); $mail->batch_enddate=date("d M, Y ",$facetoface->enddate); $tariner_name=$DB->get_record('user',array('id'=>$facetoface->trainerid)); $mail->tariner_name=fullname($tariner_name); if($facetoface_course){ if($facetoface_course->courseid!=0){ $batch_cousre=$DB->get_field('course','fullname',array('id'=>$facetoface_course->courseid)); $mail->batch_course=$batch_cousre; }else{ $mail->batch_course="-----"; } if($facetoface_course->testid!=0){ $quiz=$DB->get_record('quiz',array('id'=>$facetoface_course->testid)); $mail->test_name=$quiz->name; $course_completion_check=$DB->record_exists_sql("SELECT * FROM {course_completion_criteria} cc, {course} c Where c.id=$facetoface_course->courseid and c.id=cc.course and c.enablecompletion=1 AND cc.module IS NOT NULL AND cc.moduleinstance in (SELECT id FROM {course_modules} where course=$facetoface_course->courseid and instance=$facetoface_course->testid)"); if($course_completion_check==1){ $mail->test_status=get_string('test_completed', 'facetoface'); }else{ $mail->test_status=get_string('test_not_completed', 'facetoface'); } }else{ $mail->test_name="-----"; $mail->test_status="-----"; } } if($facetofacesessions && ($session_cancel==0 || $session_cancel==2)){ $session_mail='<h2 style="text-align:center;font-weight:bold;">SESSION DETAILS</h2>'; $session_mail.='<table style="border:1px solid #333;">'; $i=1; foreach($facetofacesessions as $sessiondate){ //print_object($sessiondate); $sessiondates=new stdClass(); $timenow = time(); 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 . ', '; } $html .= $sessionobj->starttime . ' - ' . $sessionobj->endtime . ' ' . $sessionobj->timezone; $duration=round(($sessiondate->duration/60),2); $session_mail.='<tr>'; $session_mail.='<td style="border:1px solid #333;">Session '.$i.' '.'Timings : </td>'; $session_mail.='<td style="border:1px solid #333;"><b>'.$html.'</b></td>'; $session_mail.='<td style="border:1px solid #333;">Duration : </td>'; $session_mail.='<td style="border:1px solid #333;"><b>'.$duration.' Hours </b></td>'; if ($sessiondate->roomid) { $room = $DB->get_record('facetoface_room', array('id' => $sessiondate->roomid)); $sessionroom = $room->name." ". $room->building." ".$room->address; }else{ $sessionroom = "----"; } $sessiondates->datetimeknown=$sessiondate->datetimeknown; $sessiondates->sessiondates=facetoface_get_session_dates($sessiondate->id); //print_object($sessiondates); $session_cancel=$DB->get_record_sql("SELECT * FROM {facetoface_signups} as fsg JOIN {facetoface_signups_status} as fsst on fsst.signupid=fsg.id where fsg.sessionid=$sessiondate->id group by fsg.sessionid"); if($session_cancel->statuscode==10){ $status = get_string('sessionincancel', 'facetoface'); }else{ if ($sessiondate->datetimeknown && facetoface_has_session_started($sessiondates, $timenow) && !facetoface_is_session_in_progress($sessiondates, $timenow)) { $status = get_string('sessioninprogress', 'facetoface'); } else if ($sessiondate->datetimeknown && facetoface_has_session_started($sessiondates, $timenow)&&facetoface_is_session_in_progress($sessiondates, $timenow)) { $status = get_string('sessionover', 'facetoface'); } } $session_mail.='<td style="border:1px solid #333;">Room : </td>'; $session_mail.='<td style="border:1px solid #333;"><b>'.$sessionroom.'</b></td>'; $session_mail.='<td style="border:1px solid #333;">Status : </td>'; $session_mail.='<td style="border:1px solid #333;"><b>'.$status.'</b></td>'; $session_mail.='</tr>'; $i++; } $session_mail.='</table>'; $mail->sessions_details=$session_mail; }else{ $mail->sessions_details=""; } $userenrolments=array(); foreach($facetoface_users as $facetoface_user){ $user=$DB->get_record('user',array('id'=>$facetoface_user->userid)); if($facetoface_course){ $userenrolments[]=$DB->get_record_sql("SELECT * FROM {user_enrolments} where userid=$facetoface_user->userid and enrolid in (SELECT id FROM {enrol} where courseid=$facetoface_course->courseid and enrol='manual')"); } } $emai_users=email_send_users_list($userenrolments,$facetoface_course->courseid,$facetoface->trainerid); $to_emailid=$emai_users[0]; $to_userid=$emai_users[1]; //print_object($emai_users); $from = $DB->get_record('user',array('id'=>2)); $messagetext='Batch'; if($facetoface->active==0){ $messagetext_fr=get_string('first_time_notify', 'facetoface',$tataaia); $messagehtml=text_to_html($messagetext_fr); }else{ $messagetext_fr=get_string('batch_mail', 'facetoface',$mail); $messagehtml=text_to_html($messagetext_fr); } if((!empty($to_emailid))&&(!empty($to_userid))){ $sucess=email_logs_insert_table($to_emailid,$to_userid,$from->email,$from->id,$mailsubject,$messagehtml,$sentby_id,$sentby_name,$facetoface_course->courseid,$facetofaceid); return $sucess; } } }
/** * 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; }
/** * 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; }
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); }
$PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); // Go back $url = new moodle_url('/mod/facetoface/view_sessions.php', array('f' => $facetoface->id)); echo html_writer::link($url, get_string('goback', 'facetoface')) . html_writer::end_tag('p'); } /** * Print page content */ // If taking attendance, make sure the session has already started if ($takeattendance && $session->datetimeknown && !facetoface_has_session_started($session, time())) { $link = "{$CFG->wwwroot}/mod/facetoface/attendees.php?s={$session->id}"; print_error('error:canttakeattendanceforunstartedsession', 'facetoface', $link); } if (!$onlycontent && !$download) { echo $OUTPUT->box_start(); //coded by rajesh $iconimage=html_writer::empty_tag('img', array('src'=>$CFG->wwwroot.'/mod/facetoface/pix/new.png','size'=>'15px')); echo '<div class="rooms">'; echo '<span class="roomsiconimage">'.$iconimage.'</span>'; echo '<div class="roomsheading">'. $OUTPUT->heading(format_string($facetoface->name)).'</div>'; echo '</div>'; // echo $OUTPUT->heading(format_string($facetoface->name));
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>"; }
$mform = new mod_facetoface_cancelsignup_form(null, compact('s', 'backtoallsessions')); if ($mform->is_cancelled()) { redirect($returnurl); } if ($fromform = $mform->get_data()) { // Form submitted if (empty($fromform->submitbutton)) { print_error('error:unknownbuttonclicked', 'facetoface', $returnurl); } $forcecancel = false; $timenow = time(); $bookedsession = facetoface_get_user_submissions($facetoface->id, $USER->id, MDL_F2F_STATUS_WAITLISTED, MDL_F2F_STATUS_WAITLISTED, $session->id); if (!empty($bookedsession) && facetoface_has_session_started($session, $timenow)) { $forcecancel = true; } $errorstr = ''; if (facetoface_user_cancel($session, false, $forcecancel, $errorstr, $fromform->cancelreason)) { add_to_log($course->id, 'facetoface', 'cancel booking', "cancelsignup.php?s=$session->id", $facetoface->id, $cm->id); $message = get_string('bookingcancelled', 'facetoface'); if ($session->datetimeknown) { print_object($factoface); $error = facetoface_send_cancellation_notice($facetoface, $session, $USER->id); if (empty($error)) { if ($session->datetimeknown && isset($facetoface->cancellationinstrmngr) && !empty($facetoface->cancellationstrmngr)) { $message .= html_writer::empty_tag('br') . html_writer::empty_tag('br') . get_string('cancellationsentmgr', 'facetoface');
$overstr = get_string('cannotsignupsessionover', 'facetoface'); $errorstring = facetoface_is_session_in_progress($session, $timenow) ? $inprogressstr : $overstr; echo html_writer::empty_tag('br') . $errorstring; echo $OUTPUT->box_end(); echo $OUTPUT->footer($course); exit; } if (!$signedup && !facetoface_session_has_capacity($session, $context) && !$session->allowoverbook) { print_error('sessionisfull', 'facetoface', $returnurl); echo $OUTPUT->box_end(); echo $OUTPUT->footer($course); exit; } echo facetoface_print_session($session, $viewattendees); if ($signedup) { if (!($session->datetimeknown && facetoface_has_session_started($session, $timenow))) { // Cancellation link. $cancellationurl = new moodle_url('cancelsignup.php', array('s' => $session->id, 'backtoallsessions' => $backtoallsessions)); echo html_writer::link($cancellationurl, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface'))); echo ' – '; } // See attendees link. if ($viewattendees) { $attendeesurl = new moodle_url('attendees.php', array('s' => $session->id, 'backtoallsessions' => $backtoallsessions)); echo html_writer::link($attendeesurl, get_string('seeattendees', 'facetoface'), array('title' => get_string('seeattendees', 'facetoface'))); } echo html_writer::empty_tag('br') . html_writer::link($returnurl, get_string('goback', 'facetoface'), array('title' => get_string('goback', 'facetoface'))); } else { if (facetoface_manager_needed($facetoface) && !facetoface_get_manageremail($USER->id)) { // Don't allow signup to proceed if a manager is required. // Check to see if the user has a managers email set.
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; }
//Show normal if the mod is visible $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); } }
function test_facetoface_has_session_started() { // Define test variables. $session1 = $this->sessions['sess0']; $sess0 = $this->array_to_object($session1); $sess0->sessiondates = array(0 => new stdClass()); $sess0->sessiondates[0]->timestart = time() - 100; $sess0->sessiondates[0]->timefinish = time() + 100; $session2 = $this->sessions['sess1']; $sess1 = $this->array_to_object($session2); $timenow = time(); // Test for Valid case. $this->assertTrue((bool)facetoface_has_session_started($sess0, $timenow), $this->msgtrue); // Test for invalid case. $this->assertFalse((bool)facetoface_has_session_started($sess1, $timenow), $this->msgfalse); $this->resetAfterTest(true); }