Ejemplo n.º 1
0
     // For a given date, fitness info is the last on or before that date,
     // or if there is none then the defaults apply.
     $dfrow = sqlQuery("SELECT df.*, lf.title AS lf_title, lf.mapping AS lf_mapping " . "FROM daily_fitness AS df " . "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " . "WHERE df.pid = '{$patient_id}' AND df.date <= '{$date}' " . "ORDER BY df.date DESC LIMIT 1");
 } else {
     // This is obsolete.
     $dfrow = sqlQuery("SELECT df.*, lf.title AS lf_title, lf.mapping AS lf_mapping " . "FROM daily_fitness AS df " . "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " . "WHERE df.pid = '{$patient_id}' AND df.date = '{$date}'");
 }
 if (empty($dfrow)) {
     $dfrow = array('fitness' => $fdefault['option_id'], 'lf_title' => $fdefault['title'], 'lf_mapping' => $fdefault['mapping'], 'am' => '', 'pm' => '');
 }
 $mapping = explode(':', $dfrow['lf_mapping']);
 $bgcolor = $mapping[0];
 // Compute percentage of participation.
 $eventmins = 0;
 $partmins = 0;
 $eres = getSquadEvents($date, $squadvalue, $patient_id);
 while ($erow = sqlFetchArray($eres)) {
     if (!eventMatchesDay($erow, $date)) {
         continue;
     }
     $duration = (int) ($erow['pc_duration'] / 60);
     $eventmins += $duration;
     if (empty($erow['pid']) || $erow['minutes'] > $duration) {
         $partmins += $duration;
     } else {
         $partmins += $erow['minutes'];
     }
 }
 echo "  <td class='detail' " . "bgcolor='{$bgcolor}' " . "valign='top' " . ">\n";
 if ($PROPLOGIC && (empty($dfrow['date']) || $dfrow['date'] != $date)) {
     echo '<i>' . $mapping[1] . '</i>';
Ejemplo n.º 2
0
// Get player info.
$patrow = sqlQuery("SELECT " . "fname, mname, lname, pubpid, squad " . "FROM patient_data " . "WHERE pid = '{$plid}' LIMIT 1");
$squad = $patrow['squad'];
if ($PROPLOGIC) {
    // For a given date, fitness info is the last on or before that date,
    // or if there is none then the defaults apply.
    $dfrow = sqlQuery("SELECT " . "df.*, lf.option_id AS lf_id, lf.title AS lf_title " . "FROM daily_fitness AS df " . "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " . "WHERE df.pid = '{$plid}' AND df.date <= '{$date}' " . "ORDER BY df.date DESC LIMIT 1");
} else {
    $dfrow = sqlQuery("SELECT " . "df.*, lf.option_id AS lf_id, lf.title AS lf_title " . "FROM daily_fitness AS df " . "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " . "WHERE df.pid = '{$plid}' AND df.date = '{$date}'");
}
if (empty($dfrow)) {
    $dfrow = array('pid' => '0', 'date' => '', 'fitness' => '1', 'lf_title' => 'FF', 'issue_id' => '0');
}
// This gets the events for the player's squad for this date,
// and the player-specific data (if any) for each such event.
$eres = getSquadEvents($date, $squad, $plid);
// Get the roster note, if any, for this player and date.
$nrow = sqlQuery("SELECT id, body, assigned_to FROM pnotes WHERE " . "pid = '{$plid}' AND LEFT(date,10) = '{$date}' AND title LIKE 'Roster' AND " . "deleted = 0 ORDER BY date LIMIT 1");
$noteid = empty($nrow) ? '0' : $nrow['id'];
// If the Save button was clicked...
if ($_POST['form_save']) {
    // Update daily_fitness.
    if ($dfrow['date'] == $date) {
        sqlStatement("UPDATE daily_fitness SET " . "fitness = '{$form_fitness}', " . "am = '{$form_am}', " . "pm = '{$form_pm}', " . "issue_id = '{$form_issue}'" . "WHERE pid = '{$plid}' AND date = '{$date}'");
    } else {
        sqlStatement("INSERT INTO daily_fitness SET " . "pid = '{$plid}', " . "date = '{$date}', " . "fitness = '{$form_fitness}', " . "am = '{$form_am}', " . "pm = '{$form_pm}', " . "issue_id = '{$form_issue}'");
    }
    // Update player_events.
    while ($erow = sqlFetchArray($eres)) {
        if (!eventMatchesDay($erow, $date)) {
            continue;