Beispiel #1
0
function new_hours(&$state)
{
    $logdate = clone $state->from_date;
    if ($state->columns < 0 && $state->row == 0) {
        //add a rec in list style
        if (!audit_date($state, $logdate)) {
            return;
        }
    }
    $status = array();
    if (!audit_hours($state, $logdate, $status)) {
        return;
    }
    //adding a row but didn't select existing activity:
    if ($state->row == 0 && $state->activity_id == 0) {
        add_activity($state);
    }
    for ($ndx = 0; $ndx < abs($state->columns); $ndx++, $logdate->add(new DateInterval('P1D'))) {
        switch ($status[$ndx]) {
            case 'a':
                //add
                add_log($state, $logdate, $ndx);
                break;
            case 'u':
                //update
                update_log($state, $logdate, $ndx);
                break;
            case 'd':
                //delete
                delete_log($state, $logdate, $ndx);
                break;
        }
    }
}
function new_info(&$db, &$state)
{
    if (!isset($_POST["recID"])) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST", true);
    }
    if (!audit_counts($db, $state)) {
        return false;
    }
    $recID = $_POST["recID"];
    if ($recID == 0) {
        //adding
        add_log($db, $state);
        return true;
    }
    log_list($db, $state);
    if (!array_key_exists(strval($recID), $state->records)) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid recID " . $recID, true);
    }
    if ($state->records[$recID]["event_id"] != $_POST["event"]) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid record " . $recID, true);
    }
    if ($_POST["sessions"] == 0) {
        delete_log($db, $state);
    } else {
        update_log($db, $state);
    }
    return true;
}
Beispiel #3
0
function new_hours(&$state)
{
    log_list($state, $state->row);
    //find this row's records
    //Do audits:
    if ($state->mode == "t") {
        $logdate = clone $state->from_date;
    } elseif ($state->row == 0) {
        //adding in List mode
        $logdate = clone $state->logdate;
        //created by DATE_PICK
    } else {
        $record = reset($state->records);
        //updating in list mode
        $logdate = clone $record["logdate"];
    }
    $status = array();
    if (!audit_hours($state, $logdate, $status)) {
        return;
    }
    //Do DB changes:
    //	adding a row but didn't select existing activity:
    if ($state->row == 0 && $state->activity_id == 0) {
        add_activity($state);
    }
    $columns = $state->mode == "l" ? 1 : $state->columns[COL_COUNT];
    for ($ndx = 0; $ndx < $columns; $ndx++, $logdate->add(new DateInterval('P1D'))) {
        switch ($status[$ndx]) {
            case 'a':
                //add
                add_log($state, $logdate, $ndx);
                break;
            case 'u':
                //update
                update_log($state, $ndx);
                break;
            case 'd':
                //delete
                delete_log($state, $ndx);
                break;
        }
    }
}
Beispiel #4
0
function new_counts(&$state)
{
    log_list($state, $state->row);
    //find this row's records
    $state->recID = 0;
    if ($state->row > 0) {
        //updating (0 is add row)
        $record = reset($state->records);
        if ($record["ID"] == 0) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST 1", true);
        }
        $state->recID = $record["ID"];
    }
    if (!audit_counts($state)) {
        return;
    }
    if (substr($_POST["comments"], 0, 1) == "\n") {
        $_POST["comments"] = "---";
    }
    $logdate = clone $state->from_date;
    if ($state->row == 0) {
        //adding
        add_log($state, $state->logdate);
        return;
    }
    if ($record["event_id"] != $_POST["event"] || $record["account_id"] != $_POST["account"]) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid record " . $recID, true);
    }
    if ($_POST["sessions"] == 0) {
        delete_log($state);
    } else {
        update_log($state);
    }
}
Beispiel #5
0
function new_info(&$state)
{
    $state->recID = 0;
    if ($state->row > 0) {
        //0 is add row
        log_list($state);
        foreach ($state->records as $recID => $record) {
            $state->recID = $recID;
            if ($record["row"] == $state->row) {
                break;
            }
        }
        if ($state->recID == 0) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST", true);
        }
    }
    if (!audit_counts($state)) {
        return false;
    }
    if (substr($_POST["comments"], 0, 1) == "\n") {
        $_POST["comments"] = "---";
    }
    $logdate = clone $state->from_date;
    if ($state->recID == 0) {
        //adding
        if (!audit_date($state, $logdate)) {
            return false;
        }
        add_log($state);
        return;
    }
    if ($state->records[$state->recID]["event_id"] != $_POST["event"] || $state->records[$state->recID]["account_id"] != $_POST["account"]) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid record " . $recID, true);
    }
    if ($_POST["sessions"] == 0) {
        delete_log($state);
    } else {
        update_log($state);
    }
}
Beispiel #6
0
function new_amount(&$state)
{
    log_list($state, $state->row);
    //find this row's records
    //Do audits:
    $record = reset($state->records);
    if ($state->type == "") {
        $state->type = $record["type"];
    }
    $status = "";
    if (!audit_amount($state, $status)) {
        return;
    }
    //Do DB changes:
    //	adding a row but didn't select existing activity:
    if ($state->row == 0 && $state->activity_id == 0) {
        add_activity($state);
    }
    switch ($status) {
        case 'a':
            //add
            add_log($state);
            break;
        case 'u':
            //update
            update_log($state);
            break;
        case 'd':
            //delete
            delete_log($state);
            break;
    }
}
Beispiel #7
0
function new_info(&$state)
{
    global $_DB;
    $state->recID = 0;
    if ($state->process == "u") {
        log_list($state);
        foreach ($state->records as $recID => $record) {
            $state->recID = $recID;
            if ($record["row"] == $state->row) {
                break;
            }
        }
        if ($state->recID == 0) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST", true);
        }
    }
    if (!audit_counts($state)) {
        return false;
    }
    if (substr($_POST["comments"], 0, 1) == "\n") {
        $_POST["comments"] = "---";
    }
    if ($state->recID == 0) {
        //adding
        add_log($state);
        return true;
    }
    if ($state->records[$state->recID]["event_id"] != $_POST["event"]) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid record " . $recID, true);
    }
    if ($_POST["sessions"] == 0) {
        delete_log($state);
    } else {
        update_log($state);
    }
    return true;
}