/** * Prepares the data to be sent with confirmation mail * * @param stdClass $booking * @param stdClass $option * @param stdClass $user * @param int $cmid * @return stdClass data to be sent via mail */ function booking_generate_email_params(stdClass $booking, stdClass $option, stdClass $user, $cmid) { global $CFG; require_once $CFG->libdir . '/tcpdf/tcpdf_barcodes_2d.php'; $params = new stdClass(); $timeformat = get_string('strftimetime'); $dateformat = get_string('strftimedate'); $duration = ''; if ($option->coursestarttime && $option->courseendtime) { $seconds = $option->courseendtime - $option->coursestarttime; $duration = booking_pretty_duration($seconds); } $courselink = ''; if ($option->courseid) { $courselink = new moodle_url('/course/view.php', array('id' => $option->courseid)); $courselink = html_writer::link($courselink, $courselink->out()); } $bookinglink = new moodle_url('/mod/booking/view.php', array('id' => $cmid)); $bookinglink = $bookinglink->out(); //$barcodeobj = new TCPDF2DBarcode($user->id, 'QRCODE,H'); //$params->qr_id = $barcodeobj->getBarcodePng(4, 4); $params->qr_id = '<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=' . rawurlencode($user->id) . '&choe=UTF-8" title="Link to Google.com" />'; //$barcodeobj->setBarcode($user->username, 'QRCODE,H'); //$params->qr_username = $barcodeobj->getBarcodeHTML(4, 4); $params->qr_username = '******' . rawurlencode($user->username) . '&choe=UTF-8" title="Link to Google.com" />'; $params->status = booking_get_user_status($user->id, $option->id, $booking->id, $cmid); $params->participant = fullname($user); $params->title = s($option->text); $params->duration = $booking->duration; $params->starttime = $option->coursestarttime ? userdate($option->coursestarttime, $timeformat) : ''; $params->endtime = $option->courseendtime ? userdate($option->courseendtime, $timeformat) : ''; $params->startdate = $option->coursestarttime ? userdate($option->coursestarttime, $dateformat) : ''; $params->enddate = $option->courseendtime ? userdate($option->courseendtime, $dateformat) : ''; $params->courselink = $courselink; $params->bookinglink = $bookinglink; $params->location = $option->location; $params->institution = $option->institution; $params->address = $option->address; $params->eventtype = $booking->eventtype; $params->pollstartdate = $option->coursestarttime ? userdate((int) $option->coursestarttime, get_string('pollstrftimedate', 'booking')) : ''; if (empty($option->pollurl)) { $params->pollurl = $booking->pollurl; } else { $params->pollurl = $option->pollurl; } if (empty($option->pollurlteachers)) { $params->pollurlteachers = $booking->pollurlteachers; } else { $params->pollurlteachers = $option->pollurlteachers; } return $params; }
/** * Prepares the data to be sent with confirmation mail * * @param stdClass $booking * @param stdClass $option * @param stdClass $user * @param int $cmid * @return stdClass data to be sent via mail */ function booking_generate_email_params(stdClass $booking, stdClass $option, stdClass $user, $cmid) { $params = new stdClass(); $timeformat = get_string('strftimetime'); $dateformat = get_string('strftimedate'); $duration = ''; if ($option->coursestarttime && $option->courseendtime) { $seconds = $option->courseendtime - $option->coursestarttime; $duration = booking_pretty_duration($seconds); } $courselink = ''; if ($option->courseid) { $courselink = new moodle_url('/course/view.php', array('id' => $option->courseid)); $courselink = html_writer::link($courselink, $courselink->out()); } $bookinglink = new moodle_url('/mod/booking/view.php', array('id' => $cmid)); $bookinglink = $bookinglink->out(); $params->status = booking_get_user_status($user->id, $option->id, $booking->id, $cmid); $params->participant = fullname($user); $params->title = s($option->text); $params->duration = $booking->duration; $params->starttime = $option->coursestarttime ? userdate($option->coursestarttime, $timeformat) : ''; $params->endtime = $option->courseendtime ? userdate($option->courseendtime, $timeformat) : ''; $params->startdate = $option->coursestarttime ? userdate($option->coursestarttime, $dateformat) : ''; $params->enddate = $option->courseendtime ? userdate($option->courseendtime, $dateformat) : ''; $params->courselink = $courselink; $params->bookinglink = $bookinglink; $params->location = $option->location; $params->institution = $option->institution; $params->address = $option->address; $params->eventtype = $booking->eventtype; if (empty($option->pollurl)) { $params->pollurl = $booking->pollurl; } else { $params->pollurl = $option->pollurl; } if (empty($option->pollurlteachers)) { $params->pollurlteachers = $booking->pollurlteachers; } else { $params->pollurlteachers = $option->pollurlteachers; } return $params; }