\n"; echo "
\n"; echo "shift evaluation from "; printf(" to\n", $startdate); printf("\n", $stopdate); echo " \n"; echo "\n"; include ("db.php"); $db_id = mysql_connect($host, $user, $pw); $querynames="SELECT count(*), u FROM calendar.data "; $querynames.=" WHERE u NOT IN ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') "; $querynames.=" AND NOT x=1 "; $querynames.=" GROUP BY u ORDER BY u;"; //$queryscales="select count(*), concat(y,if(m+1<10, concat('0',m), m+1),if (d<10, concat('0',d),d)) from calendar.data where u not in ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') group by y,m,d order by u;"; $resultnames = mysql_query($querynames); //$resultscales = mysql_query($queryscales); while ($rownames = mysql_fetch_row($resultnames)) { $sum=0; //$querynights="select fNight, fStartObservation, fStopObservation, Time_to_Sec(Timediff(fStopObservation, fStartObservatioN))/60./60., (Select count(*) from calendar.data where u not in ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') and y=Date_format(fNight, '%Y') and m=Date_format(fNight, '%m')-1 and d=Date_format(fNight,'%d') and u='".$rownames[1]."' group by y,m,d) from factdata.observationtimes;"; $querynights="SELECT fNight, fStartObservation, fStopObservation, Time_to_Sec(Timediff(fStopObservation, fStartObservatioN))/60./60.+1, "; $querynights.=" (SELECT COUNT(*) FROM calendar.data WHERE u NOT IN ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') AND NOT x=1 "; $querynights.=" AND y=DATE_FORMAT(fNight, '%Y') AND m=DATE_FORMAT(fNight, '%m')-1 AND d=DATE_FORMAT(fNight,'%d') "; $querynights.=" GROUP BY y,m,d), (SELECT COUNT(*) FROM calendar.data WHERE u NOT IN ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') AND NOT x=1 "; $querynights.=" AND y=DATE_FORMAT(fNight, '%Y') AND m=DATE_FORMAT(fNight, '%m')-1 AND d=DATE_FORMAT(fNight,'%d') "; $querynights.=" AND u='".$rownames[1]."' GROUP BY y,m,d) FROM factdata.observationtimes "; $querynights.=" WHERE fNight>=".$startdate." and fNight<=".$stopdate; $resultnights = mysql_query($querynights); while ($rownights = mysql_fetch_row($resultnights)) { if ($rownights[5]>0) { //echo $rownights[0]." ".$rownights[1]." ".$rownights[2]." ".$rownights[3]." ".$rownights[4]."
"; $sum+=$rownights[3]/$rownights[4]; } } echo "\n\n\n"; mysql_free_result($resultnights); } //$sumhours+=$hours*scale mysql_free_result($resultnames); //mysql_free_result($resultscales); echo "
".$rownames[1]."".$sum."
\n
\n"; echo "Debugging times:
\n"; echo "\n"; $querynames="SELECT count(*), u FROM calendar.data "; $querynames.=" WHERE u NOT IN ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') "; $querynames.=" AND NOT x=0 "; $querynames.=" GROUP BY u ORDER BY u;"; //$queryscales="select count(*), concat(y,if(m+1<10, concat('0',m), m+1),if (d<10, concat('0',d),d)) from calendar.data where u not in ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') group by y,m,d order by u;"; $resultnames = mysql_query($querynames); //$resultscales = mysql_query($queryscales); while ($rownames = mysql_fetch_row($resultnames)) { $sum=0; $querynights="SELECT fNight, fStartObservation, fStopObservation, Time_to_Sec(Timediff(fStopObservation, fStartObservation))/60./60.+1, "; $querynights.=" (SELECT COUNT(*) FROM calendar.data WHERE u NOT IN ('ETHZ', 'ISDC', 'UNIDO', 'UNIWUE') AND NOT x=0 "; $querynights.=" AND y=DATE_FORMAT(fNight, '%Y') AND m=DATE_FORMAT(fNight, '%m')-1 AND d=DATE_FORMAT(fNight,'%d') "; $querynights.=" AND u='".$rownames[1]."' GROUP BY y,m,d) FROM factdata.observationtimes "; $querynights.=" WHERE fNight>=".$startdate." and fNight<=".$stopdate; $resultnights = mysql_query($querynights); while ($rownights = mysql_fetch_row($resultnights)) { if ($rownights[4]>0) { //echo $rownights[0]." ".$rownights[1]." ".$rownights[2]." ".$rownights[3]." ".$rownights[4]."
"; $sum+=$rownights[3]*0.5; //$sum+=$rownights[3]/$rownights[4]; } } echo "\n\n\n"; mysql_free_result($resultnights); } //$sumhours+=$hours*scale mysql_free_result($resultnames); //mysql_free_result($resultscales); mysql_close($db_id); echo "
".$rownames[1]."".$sum."
\n"; echo "
\n"; echo "\n"; echo "\n"; ?>