Ignore:
Timestamp:
02/19/10 13:10:34 (14 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Basic support for network node references: Add, view, edit nodes and

referencess

Probably excludes a bunch of real use-cases for various reasons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/cgi-bin/main.cgi

    r390 r394  
    614614  }
    615615  $html =~ s|\$\$ALLCITIES\$\$|$cities|g;
     616
     617## node hack
     618  $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     619  $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     620  my $nodes = '';
     621  while (my ($nid,$nname) = $sth->fetchrow_array()) {
     622    $nodes .= "<option value='$nid'>$nname</option>\n";
     623  }
     624  $html =~ s/\$\$NODELIST\$\$/$nodes/;
     625## end node hack
    616626
    617627  my $i = 0;
     
    780790  close HTML;
    781791
     792## node hack
     793  if ($webvar{node} && $webvar{node} ne '-') {
     794    $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
     795    $sth->execute($webvar{node});
     796    my ($nodename) = $sth->fetchrow_array();
     797    $html =~ s/\$\$NODENAME\$\$/$nodename/;
     798    $html =~ s/\$\$NODEID\$\$/$webvar{node}/;
     799  } else {
     800    $html =~ s/\$\$NODENAME\$\$//;
     801    $html =~ s/\$\$NODEID\$\$//;
     802  }
     803## end node hack
     804
    782805### gotta fix this in final
    783806  # Stick in customer info as necessary - if it's blank, it just ends
     
    849872  my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from},
    850873        $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
    851         $webvar{circid}, $webvar{privdata});
     874        $webvar{circid}, $webvar{privdata}, $webvar{node});
    852875
    853876  if ($code eq 'OK') {
     
    10311054      $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g;
    10321055    }
     1056## node hack
     1057  $sth = $ip_dbh->prepare("SELECT node_id FROM noderef WHERE block='$webvar{block}'");
     1058  $sth->execute;
     1059  my ($nodeid) = $sth->fetchrow_array();
     1060  if ($nodeid) {
     1061    $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     1062    $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1063    my $nodes = "<select name=node>\n";
     1064    while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1065      $nodes .= "<option".($nodeid == $nid ? ' selected' : '')." value='$nid'>$nname</option>\n";
     1066    }
     1067    $nodes .= "</select>\n";
     1068    $html =~ s/\$\$NODE\$\$/$nodes/;
     1069  } else {
     1070    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     1071      $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     1072      $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1073      my $nodes = "<select name=node>\n<option value=>--</option>\n";
     1074      while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1075        $nodes .= "<option value='$nid'>$nname</option>\n";
     1076      }
     1077      $nodes .= "</select>\n";
     1078      $html =~ s/\$\$NODE\$\$/$nodes/;
     1079    } else {
     1080      $html =~ s|\$\$NODE\$\$|N/A|;
     1081    }
     1082  }
     1083## end node hack
    10331084    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
    10341085    $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g;
     
    10371088    $html =~ s|\$\$NOTES\$\$|<textarea rows="8" cols="64" name="notes" class="regular">$data[6]</textarea>|g;
    10381089  } else {
     1090## node hack
     1091    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     1092      $sth = $ip_dbh->prepare("SELECT node_name FROM nodes INNER JOIN noderef".
     1093        " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'");
     1094      $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1095      my ($node) = $sth->fetchrow_array;
     1096      $html =~ s/\$\$NODE\$\$/$node/;
     1097    } else {
     1098      $html =~ s|\$\$NODE\$\$|N/A|;
     1099    }
     1100## end node hack
    10391101    $html =~ s/\$\$CUSTID\$\$/$data[1]/g;
    10401102    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
     
    11351197    $sth = $ip_dbh->prepare($sql);
    11361198    $sth->execute;
     1199## node hack
     1200    if ($webvar{node}) {
     1201      $ip_dbh->do("DELETE FROM noderef WHERE block='$webvar{block}'");
     1202      $sth = $ip_dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
     1203      $sth->execute($webvar{block},$webvar{node});
     1204    }
     1205## end node hack
    11371206    $ip_dbh->commit;
    11381207  };
Note: See TracChangeset for help on using the changeset viewer.