Changeset 18208


Ignore:
Timestamp:
06/15/15 00:09:36 (9 years ago)
Author:
Daniela Dorner
Message:
added expert-on-call info
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/dch/shiftinfo.php

    r17532 r18208  
    1616and <a href='https://www.fact-project.org/logbook/memberlist.php'>FACT logbook<a>)
    1717
     18<!--#!/usr/bin/php-->
    1819<?php
    1920
    20 if (date("H")>8)
    21     $today=date("Ymd", mktime(0,0,0,date("m"), date("d"), date("Y")));
     21if ($argv)
     22    parse_str(implode('&', array_slice($argv, 1)), $_GET);
     23
     24if (isset($_GET['date']))
     25    $today=date("Ymd", strtotime($_GET["date"]));
    2226else
    23     $today=date("Ymd",strtotime(date("Y-m-d", mktime(0,0,0,date("m"), date("d"), date("Y")))." -1 day"));
     27{
     28    if (date("H")>8)
     29        $today=date("Ymd", mktime(0,0,0,date("m"), date("d"), date("Y")));
     30    else
     31        $today=date("Ymd",strtotime(date("Y-m-d", mktime(0,0,0,date("m"), date("d"), date("Y")))." -1 day"));
     32}
     33
     34function send_email($date, $msg_part)
     35{
     36    //echo "WARNING: no shift crew found -> need to send email.<br>\n";
     37    $to = "fact-online@lists.phys.ethz.ch";
     38    //$to = "dorner@astro.uni-wuerzburg.de";
     39    $subject = $date.": shifter-info missing";
     40    $msg = "WARNING: No shifter-info available for ".$date."\n\n";
     41    $msg .= $msg_part;
     42
     43    if (!mail($to, $subject, $msg, 'From:observations@fact-project.org'))
     44        echo "Sending warning email failed.<br>\n\n";
     45}
     46
    2447
    2548echo "<br> &nbsp;&nbsp;Night: ".$today." (date of sunset) <br>";
    26 $query="SELECT u FROM calendar.Data WHERE CONCAT(y, LPAD(m+1, 2, 0), LPAD(d,2,0))='".$today."' AND x=0 ";
    27 //echo $query;
     49$query="SELECT u FROM calendar.Data WHERE CONCAT(y, LPAD(m+1, 2, 0), LPAD(d,2,0))='".$today."'";
     50//excluding experts and institutes (apart from 'moon')
     51$query.=" AND NOT x=1 AND u NOT in('ISDC','ETHZ','TUDO','UNIWUE')";
    2852include ("db.php");
    2953$db_id = mysql_connect($host, $user, $pw);
    3054$result  = mysql_query($query);
    31 echo "&nbsp;&nbsp;Contact Info Shiftcrew: <br>\n <ul>\n";
     55$numrows=mysql_num_rows($result);
     56if ($numrows==0)
     57    send_email($today, "Whoever is on shift, please insert your name to the shift calendar!\n");
     58else
     59    echo "&nbsp;&nbsp;Contact Info Shiftcrew: <br>\n ";
     60echo "<ul>\n";
    3261while ($row = mysql_fetch_row($result))
    3362{
    34     //echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$row[0]." ";
    3563    $query2="SELECT usertitle, fid8 FROM logbook.userfields LEFT JOIN logbook.users ON (uid=ufid) WHERE username='".$row[0]."'";
    36     //echo $query2;
    3764    $result2  = mysql_query($query2);
    3865    while ($row2 = mysql_fetch_row($result2))
    3966    {
    4067        echo "<li>".$row2[0].": ".$row2[1]."</li>\n";
     68        if (!$row2[1])
     69            send_email($today, "Dear ".$row2[0].", please insert your 'Contact Info' in your logbook user-profile!");
    4170    }
    4271    mysql_free_result($result2);
     
    4574mysql_free_result($result);
    4675
    47 echo "General Contact Info: <br>\n <ul>\n";
    48 $query3="SELECT usertitle, fid8 FROM logbook.userfields LEFT JOIN logbook.users ON (uid=ufid) WHERE username='dorner'";
     76echo "Expert-On-Call Contact Info: <br>\n <ul>\n";
     77$query3="SELECT usertitle, fid8 FROM logbook.userfields LEFT JOIN logbook.users ON (uid=ufid) LEFT JOIN memberlist.experts ON (ufid=userid) WHERE now() < stop and now() > start";
    4978$result3  = mysql_query($query3);
    5079while ($row3 = mysql_fetch_row($result3))
     
    5382}
    5483mysql_free_result($result3);
     84echo "</ul>\n";
    5585
     86/*
     87echo "General Contact Info: <br>\n <ul>\n";
     88$query4="SELECT usertitle, fid8 FROM logbook.userfields LEFT JOIN logbook.users ON (uid=ufid) WHERE username='dorner'";
     89$result4  = mysql_query($query4);
     90while ($row4 = mysql_fetch_row($result4))
     91{
     92    echo "<li>".$row4[0].": ".$row4[1]."</li>\n";
     93}
     94mysql_free_result($result4);
    5695echo "</ul>\n";
     96*/
    5797
    5898?>
Note: See TracChangeset for help on using the changeset viewer.