Example #1
0
function divCableLine($coors, $CableLineId, $nodeInfo, $tmpT = FALSE)
{
    $OpenGIS = "(" . $coors[0]->lon . "," . $coors[0]->lat . ")";
    $wr['id'] = $CableLineId;
    $res = CableLine_SELECT(0, $wr, $tmpT);
    $CableLine = $res['rows'][0];
    unset($wr);
    $name = $nodeInfo['name'];
    $NetworkBoxId = $nodeInfo['NetworkBoxId'];
    $note = $nodeInfo['note'];
    $place = $nodeInfo['place'];
    $SettlementGeoSpatial = "NULL";
    $building = "NULL";
    $apartment = "NULL";
    PQuery("BEGIN WORK;");
    $res = NetworkNode_Add($name, $NetworkBoxId, $note, $OpenGIS, $SettlementGeoSpatial, $building, $apartment, $place, $tmpT);
    if (isset($res['error'])) {
        PQuery("ROLLBACK WORK;");
        return array('error' => $res['error']);
    }
    $NetworkNodeId = $res['rows'][0]['id'];
    $ins['CableType'] = $CableLine['CableType'];
    if ($CableLine['length'] != "") {
        $ins['length'] = $CableLine['length'];
    } else {
        $ins['length'] = "NULL";
    }
    $ins['name'] = $CableLine['name'] . '_' . $nodeInfo['name'];
    $ins['comment'] = $CableLine['comment'];
    $res = CableLine_INSERT($ins, $tmpT);
    if (isset($res['error'])) {
        PQuery("ROLLBACK WORK;");
        return array('error' => $res['error']);
    }
    $NCableLineId = $res['rows'][0]['id'];
    $wr['CableLine'] = $CableLineId;
    $query = 'SELECT * FROM "' . tmpTable('CableLinePoint', $tmpT) . '"' . genWhere($wr) . 'ORDER BY "sequence"';
    $res2 = PQuery($query);
    $CableLinePoints = $res2['rows'];
    for ($i = 0; $i < count($CableLinePoints); $i++) {
        $point = $CableLinePoints[$i];
        if ($point['OpenGIS'] == $OpenGIS) {
            $seq = $point['sequence'];
            $wr1 = array('sequence' => array('val' => $seq, 'sign' => '>'), 'CableLine' => $CableLineId);
            CableLinePoint_DELETE($wr1, $tmpT);
            $wr['sequence'] = $seq;
            $upd['OpenGIS'] = "NULL";
            $upd['NetworkNode'] = $NetworkNodeId;
            CableLinePoint_UPDATE($upd, $wr, $tmpT);
            break;
        }
    }
    $seq = 1;
    for ($j = $i; $j < count($CableLinePoints); $j++) {
        $point = $CableLinePoints[$j];
        $ins = array();
        foreach ($point as $key => $value) {
            if ($key != "id" && $key != "sequence") {
                if ($value != "") {
                    $ins[$key] = $value;
                } else {
                    $ins[$key] = "NULL";
                }
            }
        }
        $ins['CableLine'] = $NCableLineId;
        $ins['sequence'] = $seq++;
        if ($j == $i) {
            $ins['NetworkNode'] = $NetworkNodeId;
            $ins['OpenGIS'] = "NULL";
        }
        CableLinePoint_INSERT($ins, $tmpT);
    }
    if (isset(end($CableLinePoints)['NetworkNode'])) {
        OpticalFiberJoin_replaceCableLine($CableLine['id'], $NCableLineId, end($CableLinePoints)['NetworkNode'], $tmpT);
    }
    $res = PQuery("COMMIT WORK;");
    return array('error' => isset($res['error']) ? $res['error'] : false);
}
Example #2
0
           $comboBox_CableLine_Values[] = $rows[$i]['id'];
           $comboBox_CableLine_Text[] = $rows[$i]['length'];
           }
           $smarty->assign("combobox_cableline_values", $comboBox_CableLine_Values);
           $smarty->assign("combobox_cableline_text", $comboBox_CableLine_Text);
           $smarty->assign("combobox_cableline_selected", $cableLineId); */
        $res = NetworkNode_SELECT(0, '', '');
        $rows = $res['rows'];
        $i = -1;
        while (++$i < $res['count']) {
            $comboBox_NetworkNode_Values[] = $rows[$i]['id'];
            $comboBox_NetworkNode_Text[] = $rows[$i]['name'];
        }
        $comboBox_NetworkNode_Values[] = 'NULL';
        $comboBox_NetworkNode_Text[] = 'Нет';
        $smarty->assign("combobox_networknode_values", $comboBox_NetworkNode_Values);
        $smarty->assign("combobox_networknode_text", $comboBox_NetworkNode_Text);
        $smarty->assign("combobox_networknode_selected", $networkNodeId);
    } elseif ($_GET['mode'] == 'delete' and isset($_GET['cablelinepointid'])) {
        if ($_SESSION['class'] > 1) {
            $message = '!!!';
            showMessage($message, 0);
        }
        $wr['id'] = $_GET['cablelinepointid'];
        CableLinePoint_DELETE($wr);
        header("Refresh: 2; url=" . getenv("HTTP_REFERER"));
        $message = "Точка удалена!";
        showMessage($message, 0);
    }
    $smarty->display('CableLinePoint.tpl');
}