Example #1
0
function OpticalFiber_SELECT($sort, $wr, $tmpT = FALSE)
{
    $query = 'SELECT * FROM "' . tmpTable('OpticalFiber', $tmpT) . '"';
    if ($wr != '') {
        $query .= genWhere($wr);
    }
    if ($sort == 1) {
        $query .= ' ORDER BY "fiber"';
    } else {
        $query .= ' ORDER BY "CableLine"';
    }
    $result = PQuery($query);
    return $result;
}
Example #2
0
function getNodeFibers($nodeId, $OFJ_id = -1, $CableLine = -1, $tmpT = FALSE)
{
    $wr['NetworkNode'] = $nodeId;
    if ($OFJ_id != -1) {
        $wr['OFJ.id'] = $OFJ_id;
    }
    if ($CableLine != -1) {
        $wr['CableLine'] = $CableLine;
    }
    $query = 'SELECT "OFJ".id AS "OFJ_id", "OpticalFiber", "OpticalFiberSplice", "OF"."CableLine", "OF".fiber, "OFS"."FiberSpliceOrganizer", round("OFS".attenuation / 100.0, 2) AS attenuation, "OFS".note
		FROM "' . tmpTable('OpticalFiberJoin', $tmpT) . '" AS "OFJ"
		LEFT JOIN "' . tmpTable('OpticalFiber', $tmpT) . '" AS "OF" ON "OF".id = "OFJ"."OpticalFiber"
		LEFT JOIN "' . tmpTable('OpticalFiberSplice', $tmpT) . '" AS "OFS" ON "OFS".id = "OFJ"."OpticalFiberSplice"' . genWhere($wr) . '
		ORDER BY "OFJ"."OpticalFiberSplice"';
    $result = PQuery($query);
    return $result;
}
Example #3
0
function dropTmpTables($in_transaction = false)
{
    $tables = getTables();
    $query = $in_transaction ? '' : 'BEGIN; LOCK "MapSettings";';
    $tbl_del = "";
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $tmpT = tmpTable($table, TRUE);
        if (strlen($tbl_del) > 0) {
            $tbl_del .= ', ';
        }
        $tbl_del .= '"' . $tmpT . '"';
    }
    //$query .= ' TRUNCATE '.$tbl_del.';';
    $query .= ' DROP TABLE IF EXISTS ' . $tbl_del . ' CASCADE;';
    if (!$in_transaction) {
        $query .= ' COMMIT;';
    }
    //print($query);
    return PQuery($query);
}
Example #4
0
function saveTmpData()
{
    $query = 'BEGIN; LOCK "MapSettings";';
    $tables = getTables();
    $tbl_del = "";
    $ins = "";
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $tmpT = tmpTable($table, TRUE);
        if (strlen($tbl_del) > 0) {
            $tbl_del .= ', ';
        }
        $tbl_del .= '"' . $table . '"';
        $ins .= ' INSERT INTO "' . $table . '" SELECT * FROM "' . $tmpT . '";';
    }
    $query .= ' TRUNCATE ' . $tbl_del . ' CASCADE;' . $ins;
    $query .= ' COMMIT;';
    $res = PQuery($query);
    if (!isset($res['error'])) {
        $res = setMapLastEdit();
    }
    if (!isset($res['error'])) {
        $res = CheckData();
    }
    return $res;
}
Example #5
0
function getCableLineInfo($nodeId, $zeroFibers = -1, $tmpT = FALSE)
{
    $query = 'SELECT "ct"."tubeQuantity"*"ct"."fiberPerTube" AS "fiber",
                "clp".id AS "clpid", "cl"."name", "ct"."marking",
                "clp"."NetworkNode", "ct".id AS "ctid", "cl".id AS "clid",
                "ct"."manufacturer", "ct"."fiberPerTube"
                FROM "' . tmpTable('NetworkNode', $tmpT) . '" AS "NN"
		LEFT JOIN "' . tmpTable('CableLinePoint', $tmpT) . '" AS "clp" ON "clp"."NetworkNode"="NN"."id"
		LEFT JOIN "' . tmpTable('CableLine', $tmpT) . '" AS "cl" ON "cl".id="clp"."CableLine"
		LEFT JOIN "' . tmpTable('CableType', $tmpT) . '" AS "ct" ON "ct".id="cl"."CableType" WHERE "NN".id=' . $nodeId;
    if ($zeroFibers == -1) {
        $query .= ' AND "ct"."tubeQuantity"*"ct"."fiberPerTube" != 0';
    }
    $result = PQuery($query . ' ORDER BY fiber DESC');
    return $result;
}
Example #6
0
function getCableLinePoints($cableLine, $onlyFree = FALSE, $tmpT = FALSE)
{
    $wr['CableLine'] = $cableLine;
    $query = 'SELECT "clp".id, "clp"."OpenGIS", "clp"."meterSign", "clp"."note", "clp"."sequence",
              "NN"."OpenGIS" AS "NNOpenGIS"
              FROM "' . tmpTable('CableLinePoint', $tmpT) . '" AS "clp"
              LEFT JOIN "' . tmpTable('NetworkNode', $tmpT) . '" AS "NN" ON "NN".id = "clp"."NetworkNode"' . genWhere($wr);
    if ($onlyFree) {
        $query .= ' AND "clp"."OpenGIS" IS NOT NULL';
    }
    $query .= ' ORDER BY "sequence"';
    $result = PQuery($query);
    return $result;
}