Exemplo n.º 1
0
function createStations($stationCount, $tag, $typeId)
{
    for ($j = 0; $j < $stationCount; $j++) {
        $station = new Station();
        $tmp = sprintf("%s%02d", $tag, $j + 1);
        $station->set("tag", $tmp);
        $station->set("typeId", $typeId);
        if ($station->create() === false) {
            echo "Create Station {$tag} failed";
        }
    }
}
Exemplo n.º 2
0
function _ops_update()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = '';
    loginRequireMgmt();
    if (!loginCheckPermission(USER::MGMT_STATION)) {
        redirect("errors/401");
    }
    $itemName = "Station";
    $urlPrefix = "mgmt_station";
    $object = new Station();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            $object->merge($_POST);
            if ($object->update()) {
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $object->merge($_POST);
        transactionBegin();
        if ($object->create()) {
            transactionCommit();
            $msg = "{$itemName} created!";
        } else {
            transactionRollback();
            $msg = "{$itemName} Create failed";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}