Ejemplo n.º 1
0
function activity_select(&$state, &$HTML)
{
    if (!isset($_GET["row"])) {
        return;
    }
    $rec = strval($_GET["row"]);
    $state->activity_id = $rec;
    $state->msgStatus = "";
    if ($rec != 0) {
        activity_list($state);
        //restore the record list
        if (!array_key_exists($rec, $state->records)) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid activity " . $rec, true);
        }
        $HTML .= "cell = document.getElementById('AT_0');\n";
        $HTML .= "cell.innerHTML = '" . $state->records[$rec] . "';\n";
    }
}
Ejemplo n.º 2
0
function change_activity(&$state)
{
    global $_DB;
    if ($state->activity_id == 0) {
        //creating a new one
        add_activity($state);
    } else {
        activity_list($state);
        //restore the record list
        if (!array_key_exists($state->activity_id, $state->records)) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid activity id " . $state->activity_id, true);
        }
    }
    log_list($state, $state->row);
    //find this row's records
    $record = reset($state->records);
    $old_activity = $record["activity_id"];
    if ($state->activity_id == $old_activity) {
        return;
    }
    foreach ($state->records as $ID => $record) {
        if ($record["column"] < $state->columns[COL_OPEN]) {
            continue;
        }
        $sql = "UPDATE " . $_DB->prefix . "b00_timelog\n\t\t\t\tSET activity_idref=" . $state->activity_id . " WHERE timelog_id=" . $ID . ";";
        $_DB->exec($sql);
    }
    $sql = "SELECT COUNT(*) AS count FROM " . $_DB->prefix . "b00_timelog WHERE activity_idref=" . $old_activity . "";
    $stmt = $_DB->query($sql);
    if ($stmt->fetchObject()->count == 0) {
        $sql = "DELETE FROM " . $_DB->prefix . "b02_activity WHERE activity_id=" . $old_activity . "";
        $_DB->exec($sql);
    }
    $stmt->closeCursor();
}