Пример #1
0
    if ($txt && fetch_val("SELECT is_leaf({$src})") == 't') {
        echo "Cannot create subsource under source #{$src}. ";
        echo "Please go back and check your source reference.";
        die;
    }
    $event = $_POST['event'];
    $person = $_POST['person'];
    $tag = $_POST['tag_fk'];
    $place = $_POST['place_fk'];
    if ($place == 0) {
        $place = 1;
    }
    $note = note_to_db($_POST['event_note']);
    $event_date = pad_date($_POST['date_1']) . $_POST['date_type'] . pad_date($_POST['date_2']) . '1';
    $sort_date = parse_sort_date($_POST['sort_date'], $event_date);
    pg_query("BEGIN");
    pg_query("UPDATE EVENTS SET tag_fk={$tag}, place_fk={$place}, event_date='{$event_date}',\n                sort_date='{$sort_date}', event_note='{$note}' WHERE event_id = {$event}");
    set_last_selected_place($place);
    set_last_edit($person);
    $source_id = add_source($person, $tag, $event, $src, $txt);
    if ($tag == 31) {
        // hard-coded reference to probate
        pg_query("SELECT generate_probate_witnesses({$event})");
    }
    if ($_POST['age']) {
        // generate birth event
        add_birth($person, $event_date, $_POST['age'], $source_id);
    }
    pg_query("COMMIT");
    header("Location: {$app_root}/family.php?person={$person}");
}
Пример #2
0
    }
    $tag = $_POST['tag_fk'];
    pg_query("BEGIN");
    $event = fetch_val("\n        INSERT INTO events (\n            tag_fk,\n            place_fk,\n            event_date,\n            sort_date,\n            event_note\n        )\n        VALUES (\n            {$tag},\n            {$place},\n            '{$event_date}',\n            '{$sort_date}',\n            '{$event_note}'\n        )\n        RETURNING event_id\n    ");
    set_last_selected_place($place);
    add_participant($person, $event);
    if ($_POST['coprincipal'] && has_coprincipal($tag)) {
        // constrain to events which allows for coprincipal, ie tag_type = 2
        $coprincipal = $_POST['coprincipal'];
        add_participant($coprincipal, $event);
    }
    if ($tag == 31) {
        // hard-coded reference to probate
        pg_query("SELECT generate_probate_witnesses({$event})");
    }
    $source_id = add_source($person, $tag, $event, $src, note_to_db($txt));
    $age = $_POST['age'];
    if ($age && is_numeric($age)) {
        // generate birth event
        add_birth($person, $event_date, $age, $source_id);
    }
    if ($tag == 3) {
        // hard-coded death tag, check if died young
        if ((died_young($person) || $age && $age < 16) && fetch_val("SELECT dead_child({$person})") == 'f') {
            pg_query("INSERT INTO dead_children (person_fk) VALUES ({$person})");
            pg_query("UPDATE persons SET toponym='' WHERE person_id = {$person}");
        }
    }
    pg_query("COMMIT");
    header("Location: {$app_root}/family.php?person={$person}");
}