Changeset 19742 for trunk


Ignore:
Timestamp:
10/08/19 09:03:43 (5 years ago)
Author:
Daniela Dorner
Message:
added listing of all duties
File:
1 edited

Legend:

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

    r18882 r19742  
    3838    $institutedebughours= array ("1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0 );
    3939    $instituteexperthours= array ("1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0 );
     40    $instituteshexperthours= array ("1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0 );
     41    $instituteflareexperthours= array ("1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0 );
    4042    $institutetotalhours= array ("1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0 );
    4143    $institutes2= array ("1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0 );
     
    5254    //$experthourstotal=0;
    5355    $hourstotal=0;
     56    $hourstotal2=0;
     57    $hourstotal3=0;
    5458    $counter=0;
    5559
     
    104108        $numhours=$rowhours[0];
    105109        mysql_free_result($resulthours);
     110        $hourstotal2+=$numhours;
    106111
    107112        $queryusers="SELECT uid FROM calendar.Data LEFT JOIN logbook.users ON calendar.Data.u=logbook.users.username ";
     
    111116        $queryshifters=$queryusers." AND x=0";
    112117        $resultshifters  = mysql_query($queryshifters);
     118        if (mysql_num_rows($resultshifters)>0)
     119            $hourstotal3+=$numhours;
    113120        while ($rowshifters = mysql_fetch_row($resultshifters))
    114121        {
     
    152159
    153160        //get experts
    154         //total 1 year: 4000 hours ~10.9h/night -> 46 hours/shift slot
    155         //1 shift slot 46 hours
    156         // 4000/46 = 87
    157         // -> 87 shift slots
    158         // expert 6 slots
    159         // 87/6 -> 14.5
    160         // => expert counts 1/13 of normal time
    161         $devide=14.5;
     161        // old shift scheme:
     162        //   per period: 3 blocks with 2 shifters -> 6 slots
     163        //   expert: 2 months = 1 slot
     164        // new shift scheme:
     165        //   per period: 4 blocks with 1 shifters -> 4 slots
     166        //   expert: 1 months = 1 slot
     167        //   + SH expert
     168        // + add flare expert starting from 2014/03
     169        if ($starttimestamp->format('Ymd')<20171201)
     170            $devide=12.0;
     171        else
     172            $devide=6.0;
    162173        $queryexperts="SELECT userid FROM memberlist.experts ";
    163         $queryexperts.=" WHERE start < '".$starttimestamp->format('Y-m-d H:i:s')."'";
    164         //$queryexperts.=" AND stop > '".$stoptimestamp->format('Y-m-d H:i:s')."'";
     174        $queryexperts.=" WHERE expert=1 ";
     175        $queryexperts.=" AND start < '".$starttimestamp->format('Y-m-d H:i:s')."'";
    165176        $queryexperts.=" AND stop > '".$starttimestamp->format('Y-m-d H:i:s')."'";
    166177        $resultexperts  = mysql_query($queryexperts);
     
    177188        }
    178189        mysql_free_result($resultexperts);
     190        // sh experts
     191        if ($starttimestamp->format('Ymd')>20171201)
     192        {
     193            $devide=6.0;
     194            $queryshexperts="SELECT userid FROM memberlist.experts ";
     195            $queryshexperts.=" WHERE sh=1 ";
     196            $queryshexperts.=" AND start < '".$starttimestamp->format('Y-m-d H:i:s')."'";
     197            $queryshexperts.=" AND stop > '".$starttimestamp->format('Y-m-d H:i:s')."'";
     198            $resultshexperts  = mysql_query($queryshexperts);
     199            while ($rowshexperts = mysql_fetch_row($resultshexperts))
     200            {
     201                if (!isset($shexperthours[$rowshexperts[0]]))
     202                    $shexperthours[$rowshexperts[0]]=0;
     203
     204                $shexperthours[$rowshexperts[0]]+=$numhours/mysql_num_rows($resultshexperts)/$devide;
     205                $totalhours[$rowexperts[0]]+=$numhours/mysql_num_rows($resultshexperts)/$devide;
     206                $instituteshexperthours[$affiliation[$rowshexperts[0]]]+=$numhours/mysql_num_rows($resultshexperts)/$devide;
     207                $institutetotalhours[$affiliation[$rowshexperts[0]]]+=$numhours/mysql_num_rows($resultshexperts)/$devide;
     208                $hourstotal+=$numhours/mysql_num_rows($resultshexperts)/$devide;
     209            }
     210            mysql_free_result($resultshexperts);
     211        }
     212        // flare experts
     213        if ($starttimestamp->format('Ymd')>20140318)
     214        {
     215            $devide=6.0;
     216            $queryflareexperts="SELECT userid FROM memberlist.experts ";
     217            $queryflareexperts.=" WHERE flare=1 ";
     218            $queryflareexperts.=" AND start < '".$starttimestamp->format('Y-m-d H:i:s')."'";
     219            $queryflareexperts.=" AND stop > '".$starttimestamp->format('Y-m-d H:i:s')."'";
     220            $resultflareexperts  = mysql_query($queryflareexperts);
     221            while ($rowflareexperts = mysql_fetch_row($resultflareexperts))
     222            {
     223                if (!isset($flareexperthours[$rowflareexperts[0]]))
     224                    $flareexperthours[$rowflareexperts[0]]=0;
     225
     226                $flareexperthours[$rowflareexperts[0]]+=$numhours/mysql_num_rows($resultflareexperts)/$devide;
     227                $totalhours[$rowexperts[0]]+=$numhours/mysql_num_rows($resultflareexperts)/$devide;
     228                $instituteflareexperthours[$affiliation[$rowflareexperts[0]]]+=$numhours/mysql_num_rows($resultflareexperts)/$devide;
     229                $institutetotalhours[$affiliation[$rowflareexperts[0]]]+=$numhours/mysql_num_rows($resultflareexperts)/$devide;
     230                $hourstotal+=$numhours/mysql_num_rows($resultflareexperts)/$devide;
     231            }
     232            mysql_free_result($resultflareexperts);
     233        }
    179234
    180235        date_add($starttimestamp, date_interval_create_from_date_string("1 days"));
     
    188243
    189244    echo "<br>\n<br>\n";
    190     echo "<b>Total number of hours:</b> ".$hourstotal." h.";
     245    //echo "<b>Total number of hours:</b> ".$hourstotal2." h (all nights).<br>\n";
     246    //echo "<b>Total number of hours:</b> ".$hourstotal3." h (all data taking nights).<br>\n";
     247    //echo "<b>Total number of hours:</b> ".$hourstotal." h (all data taking nights incl expert hours).\n";
     248    echo "<b>Total number of hours (all duties):</b> ".$hourstotal." h.<br>\n";
     249    echo "<b>Total number of hours (shift duties):</b> ".$hourstotal3." h.\n";
    191250    echo "<table>\n";
    192     echo "<tr><td align='center'><b>institute</b></td><td align='center'>hours (shift/debug/expert)</td><td>share required:done->fulfilled</td></tr>\n";
     251    echo "<tr><td align='center'><b>institute</b></td><td align='center'>hours (shift/debug/expert/flare/sh)</td><td>share required:done->fulfilled</td></tr>\n";
    193252    foreach ($institutenames as $id=>$name)
    194253    {
     
    202261        echo $name;//."(".$id.")";
    203262        echo "</td><td align='right'>";
    204         printf("%7.2f (%7.2f/%7.2f/%7.2f)",$institutetotalhours[$id],$instituteshifthours[$id],$institutedebughours[$id],$instituteexperthours[$id]);
     263        printf("%7.2f (%7.2f/%7.2f/%7.2f/%7.2f/%7.2f)",$institutetotalhours[$id],$instituteshifthours[$id],$institutedebughours[$id],$instituteexperthours[$id],$instituteflareexperthours[$id],$instituteshexperthours[$id]);
    205264        echo "</td><td align='right'>";
    206265        printf("%7.2f%%: %7.2f%% -> %5.2f%%",$institutes2[$id]*100, $institutetotalhours[$id]/$hourstotal*100, ($institutetotalhours[$id]/$hourstotal)/$institutes2[$id]*100);
     
    210269
    211270    echo "<table>\n";
    212     echo "<tr><td align='center'><b>user</b></td><td align='center'>hours(shift/debug/expert)</td></tr>\n";
     271    echo "<tr><td align='center'><b>user</b></td><td align='center'>hours(shift/debug/expert/flare/sh)</td></tr>\n";
    213272    foreach ($users as $name=>$id)
    214273    {
     
    226285        echo $name;//." (".$id.")";
    227286        echo "</td><td align='right'>";
    228         printf("%5.2f (%5.2f/%5.2f/%5.2f)",$totalhours[$id],$shifthours[$id],$debughours[$id],$experthours[$id]);
     287        printf("%5.2f (%5.2f/%5.2f/%5.2f/%5.2f/%5.2f)",$totalhours[$id],$shifthours[$id],$debughours[$id],$experthours[$id],$flareexperthours[$id],$shexperthours[$id]);
    229288        echo "</td></tr>\n";
    230289    }
Note: See TracChangeset for help on using the changeset viewer.