Exemplo n.º 1
0
function mult_time_to_sesstime($line, $pre)
{
    return helpers__pad_number($line[$pre . 'year'], 4) . helpers__pad_number($line[$pre . 'month'], 2) . helpers__pad_number($line[$pre . 'day'], 2) . helpers__pad_number($line[$pre . 'hour'], 2) . helpers__pad_number($line[$pre . 'minute'], 2);
}
Exemplo n.º 2
0
function participant__select_numbers($ptablevarname, $formfieldvarname, $prevalue, $begin, $end, $fillzeros = 2, $steps = 1, $reverse = false, $incnone = false, $existing = false, $where = '', $show_count = false)
{
    $out = '';
    $out .= '<select name="' . $formfieldvarname . '">';
    if ($incnone) {
        $out .= '<option value="">-</option>';
    }
    if (!$existing) {
        if ($begin < $end) {
            $lb = $begin;
            $ub = $end;
        } else {
            $lb = $end;
            $ub = $begin;
        }
        if ($reverse) {
            $i = $ub;
        } else {
            $i = $lb;
        }
        if ($steps < 1) {
            $steps = 1;
        }
        while ($reverse == false && $i <= $ub || $reverse == true && $i >= $lb) {
            $out .= '<option value="' . $i . '"';
            if ($i == (int) $prevalue) {
                $out .= ' SELECTED';
            }
            $out .= '>';
            $out .= helpers__pad_number($i, $fillzeros);
            $out .= '</option>';
            if ($reverse) {
                $i = $i - $steps;
            } else {
                $i = $i + $steps;
            }
        }
    } else {
        $query = "SELECT count(*) as tf_count, " . $ptablevarname . " as tf_value\n                FROM " . table('participants') . "\n                WHERE " . table('participants') . ".participant_id IS NOT NULL ";
        if ($where) {
            $query .= " AND " . $where . " ";
        }
        $query .= " GROUP BY " . $ptablevarname . "\n                  ORDER BY " . $ptablevarname;
        if ($reverse) {
            $query .= " DESC ";
        }
        $result = or_query($query);
        $listitems = array();
        while ($line = pdo_fetch_assoc($result)) {
            if (!isset($listitems[$line['tf_value']])) {
                $listitems[$line['tf_value']] = $line;
            } else {
                $listitems[$line['tf_value']]['tf_count'] = $listitems[$line['tf_value']]['tf_count'] + $line['tf_count'];
            }
        }
        foreach ($listitems as $line) {
            $out .= '<option value="' . $line['tf_value'] . '"';
            if ($line['tf_value'] == (int) $prevalue) {
                $out .= ' SELECTED';
            }
            $out .= '>';
            if ($line['tf_value'] != '') {
                $out .= helpers__pad_number($line['tf_value'], $fillzeros);
            } else {
                $out .= '-';
            }
            if ($show_count) {
                $out .= ' (' . $line['tf_count'] . ')';
            }
            $out .= '</option>';
        }
        while ($line = pdo_fetch_assoc($result)) {
            $out .= '<option value="' . $line['tf_value'] . '"';
            if ($line['tf_value'] == (int) $prevalue) {
                $out .= ' SELECTED';
            }
            $out .= '>';
            $out .= helpers__pad_number($line['tf_value'], $fillzeros);
            if ($show_count) {
                $out .= ' (' . $line['tf_count'] . ')';
            }
            $out .= '</option>';
        }
    }
    $out .= '</select>';
    return $out;
}
Exemplo n.º 3
0
function ortime__array_ampm_time_to_array_mil_time($a)
{
    // unused?
    $r = array();
    $p = strtolower($a['a']);
    $h = $a['h'] == 12 ? 0 : $a['h'];
    $r['h'] = $p == 'pm' ? $h + 12 : $h;
    $r['h'] = helpers__pad_number($r['h'], 2);
    $r['i'] = $a['i'];
    return $r;
}
Exemplo n.º 4
0
function helpers__select_hour($name, $prevalue, $begin, $end, $steps = 1, $military = true)
{
    $out = '';
    $i = $begin;
    $out .= '<select name="' . $name . '" id="' . $name . '">';
    while ($i <= $end) {
        $out .= '<option value="' . $i . '"';
        if ($i == (int) $prevalue) {
            $out .= ' SELECTED';
        }
        $out .= '>';
        if ($military) {
            $out .= helpers__pad_number($i, 2);
        } else {
            $ampm = $i < 12 ? 'am' : 'pm';
            if ($i == 0) {
                $display = 12;
            } elseif ($ampm == 'pm' && $i > 12) {
                $display = $i - 12;
            } else {
                $display = $i;
            }
            $out .= $display . $ampm;
        }
        $out .= '</option>
            ';
        $i = $i + $steps;
    }
    $out .= '</select>';
    return $out;
}