Is FACT taking data?
Who is on shift?
(from FACT shift plan
and FACT logbook)
8)
$today=date("Ymd", mktime(0,0,0,date("m"), date("d"), date("Y")));
else
$today=date("Ymd",strtotime(date("Y-m-d", mktime(0,0,0,date("m"), date("d"), date("Y")))." -1 day"));
}
function send_email($date, $msg_part)
{
$to = "fact-online@lists.phys.ethz.ch";
$subject = $date.": shifter-info missing";
$msg = "WARNING: No shifter-info available for ".$date."\n\n";
$msg .= $msg_part;
if (!mail($to, $subject, $msg, 'From:observations@fact-project.org'))
echo "Sending warning email failed.
\n\n";
}
function get_userinfo($db, $username)
{
// this is getting exactly one entry from the DB, since we get only
// one username, which is unique in the DB.
$query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype
FROM logbook.userfields
LEFT JOIN logbook.users
ON (uid=ufid)
WHERE username='".$username."'";
$result = $db->query($query);
$all = $result->fetch_assoc();
$result->free();
return $all;
}
function get_expertinfo($db)
{
$query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype
FROM logbook.userfields
LEFT JOIN logbook.users ON (uid=ufid)
LEFT JOIN memberlist.experts
ON (ufid=userid)
WHERE now() < stop and now() > start";
$result = $db->query($query);
$all = $result->fetch_all(MYSQLI_ASSOC);
$result->free();
return $all;
}
function userinfo_to_string($userinfo){
$s = $userinfo['name'] . "[" .$userinfo['login']."]" . ":
";
$s .= " email:" . $userinfo['email'] . "
";
$s .= " mobile:" . $userinfo['mobile'] . "
";
$s .= " skype:" . $userinfo['skype'] . "
";
return $s;
}
function send_warning_mail_to_user($userinfo){
$msg = "Dear " . $userinfo['name'] . "[".$userinfo['login']."]" ."\n\n";
$msg .= ", please insert your 'Shifthelper Mobile Phone Number' in ";
$msg .= ' https://www.fact-project.org/logbook/usercp.php?action=profile';
send_email($today, $msg);
}
echo "
Night: ".$today." (date of sunset)
";
$query="SELECT u FROM calendar.Data WHERE CONCAT(y, LPAD(m+1, 2, 0), LPAD(d,2,0))='".$today."'";
$query.=" AND NOT x=1 AND u NOT in('ISDC','ETHZ','TUDO','UNIWUE')";
include ("db.php");
$db = new mysqli($host, $user, $pw, $database);
$db->set_charset("utf8");
$result = $db->query($query);
$numrows=mysqli_num_rows($result);
if ($numrows==0)
send_email($today, "Whoever is on shift, please insert your name to the shift calendar!\n");
else
echo " Contact Info Shiftcrew:
\n ";
echo "\n";
while ($row = $result->fetch_assoc())
{
$userinfo = get_userinfo($db, $row['u']);
if ($userinfo['name']){
echo "- ".userinfo_to_string($userinfo)."
\n";
if (!$userinfo['mobile'])
send_warning_mail_to_user($userinfo);
}
}
echo "
\n
\n
\n ";
$result->free();
echo "Expert-On-Call Contact Info:
\n \n";
foreach (get_expertinfo($db) as $expertinfo) {
echo "- ".userinfo_to_string($expertinfo)."
\n";
}
echo "
\n";
?>