Exemplo n.º 1
0
function get_current_timer()
{
    global $kga, $conn;
    $user = MySQL::SQLValue($kga['usr']['usr_ID'], MySQL::SQLVALUE_NUMBER);
    $p = $kga['server_prefix'];
    $conn->Query("SELECT zef_ID,zef_in,zef_time FROM {$p}zef WHERE zef_usrID = {$user} ORDER BY zef_in DESC LIMIT 1;");
    $row = $conn->RowArray(0, MYSQL_ASSOC);
    $zef_time = (int) $row['zef_time'];
    $zef_in = (int) $row['zef_in'];
    if (!$zef_time && $zef_in) {
        $aktuelleMessung = hourminsec(time() - $zef_in);
        $current_timer['all'] = $zef_in;
        $current_timer['hour'] = $aktuelleMessung['h'];
        $current_timer['min'] = $aktuelleMessung['i'];
        $current_timer['sec'] = $aktuelleMessung['s'];
    } else {
        $current_timer['all'] = 0;
        $current_timer['hour'] = 0;
        $current_timer['min'] = 0;
        $current_timer['sec'] = 0;
    }
    return $current_timer;
}
Exemplo n.º 2
0
/**
 * returns time of currently running event recording as array
 *
 * result is meant as params for the stopwatch if the window is reloaded
 *
 * <pre>
 * returns:
 * [all] start time of entry in unix seconds (forgot why I named it this way, sorry ...)
 * [hour]
 * [min]
 * [sec]
 * </pre>
 *
 * @param integer $user ID of user in table usr
 * @global array $kga kimai-global-array
 * @return array
 * @author th
 */
function get_current_timer()
{
    global $kga, $pdo_conn;
    $p = $kga['server_prefix'];
    $pdo_query = $pdo_conn->prepare("SELECT zef_ID,zef_in,zef_time FROM {$p}zef WHERE zef_usrID = ? ORDER BY zef_in DESC LIMIT 1;");
    $pdo_query->execute(array($kga['usr']['usr_ID']));
    $row = $pdo_query->fetch(PDO::FETCH_ASSOC);
    $zef_time = (int) $row['zef_time'];
    $zef_in = (int) $row['zef_in'];
    if (!$zef_time && $zef_in) {
        $aktuelleMessung = hourminsec(time() - $zef_in);
        $current_timer['all'] = $zef_in;
        $current_timer['hour'] = $aktuelleMessung['h'];
        $current_timer['min'] = $aktuelleMessung['i'];
        $current_timer['sec'] = $aktuelleMessung['s'];
    } else {
        $current_timer['all'] = 0;
        $current_timer['hour'] = 0;
        $current_timer['min'] = 0;
        $current_timer['sec'] = 0;
    }
    return $current_timer;
}