Changeset 17705 for trunk/FACT++/www


Ignore:
Timestamp:
04/28/14 11:17:30 (11 years ago)
Author:
tbretz
Message:
Added more checks for the schedule.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/www/schedule/save.php

    r17701 r17705  
    130130}
    131131
     132// ================================================================
     133
     134$db = mysql_connect($dbhost,$dbuser,$dbpass);
     135if (!$db)
     136    die(mysql_error());
     137
     138if (!mysql_select_db($dbname, $db))
     139    die(mysql_error());
     140
     141$query = "SELECT * FROM measurement";
     142
     143$sql = mysql_query($query);
     144if (!$sql)
     145    die(mysql_error());
     146
     147$measurements = array();
     148while($row = mysql_fetch_assoc($sql))
     149    $measurements[$row['fMeasurementKey']] = $row;
     150
    132151// ----------------------------------------------------------------
    133152
     
    144163{
    145164    $t = $row[0]; // time
    146     $m = $row[1]; // measurement
    147     $s = $row[2]; // source
    148     $v = $row[3]; // value
    149 
    150     // If there is a time set, remember the time, if not
    151     // this is just a measurement within an observation
    152     // so duplicate the time
     165
     166    // If there is a time set (first task in an observation),
     167    // remember the time, if not this is just a measurement
     168    // within an observation so duplicate the time
    153169    if (!isset($t))
    154170    {
     
    173189    else
    174190    {
     191        // Check all but the last task in a measurement whether
     192        // the are not unlimited
     193        if ($last==$t)
     194        {
     195            if ($measurements[$m]['fIsUnlimited']==true)
     196                die("Unlimited task '".$measurements[$m]['fMeasurement']."' detected before end of observation\n[".$last."|".($id-1)."]");
     197        }
     198
    175199        if ($last>$t)
    176200            die("Times not sequential\n[".$last."|".$t."]");
    177201        $last = $t;
    178202    }
     203
     204    $m = $row[1]; // measurement
     205    $s = $row[2]; // source
     206    $v = $row[3]; // value
     207
     208    if ($measurements[$m]['fNeedsSource']==true && $s==0)
     209        die("Task '".$measurements[$m]['fMeasurement']."' needs source.\n[".$t."|".$id."]");
     210    if ($measurements[$m]['fNeedsSource']!=true && $s>0)
     211        die("Task '".$measurements[$m]['fMeasurement']."' must not have source.\n[".$t."|".$id."]");
    179212
    180213    // Compile query
     
    222255// ================================================================
    223256
    224 $db = mysql_connect($dbhost,$dbuser,$dbpass);
    225 if (!$db)
    226     die(mysql_error());
    227 
    228 if (!mysql_select_db($dbname, $db))
    229     die(mysql_error());
    230 
    231257foreach ($queries as $query)
    232258    if (!mysql_query($query))
Note: See TracChangeset for help on using the changeset viewer.