Changeset 397 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
05/10/10 17:33:13 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

Merge basic node-tracking from r393:396 into trunk. See #13.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r380 r397  
    126126elsif($webvar{action} eq 'finaldelete') {
    127127  finalDelete();
     128}
     129elsif ($webvar{action} eq 'nodesearch') {
     130  open HTML, "<../nodesearch.html";
     131  my $html = join('',<HTML>);
     132  close HTML;
     133
     134  $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     135  $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     136  my $nodes = '';
     137  while (my ($nid,$nname) = $sth->fetchrow_array()) {
     138    $nodes .= "<option value='$nid'>$nname</option>\n";
     139  }
     140  $html =~ s/\$\$NODELIST\$\$/$nodes/;
     141
     142  print $html;
    128143}
    129144
     
    613628  }
    614629  $html =~ s|\$\$ALLCITIES\$\$|$cities|g;
     630
     631## node hack
     632  $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     633  $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     634  my $nodes = '';
     635  while (my ($nid,$nname) = $sth->fetchrow_array()) {
     636    $nodes .= "<option value='$nid'>$nname</option>\n";
     637  }
     638  $html =~ s/\$\$NODELIST\$\$/$nodes/;
     639## end node hack
    615640
    616641  my $i = 0;
     
    779804  close HTML;
    780805
     806## node hack
     807  if ($webvar{node} && $webvar{node} ne '-') {
     808    $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
     809    $sth->execute($webvar{node});
     810    my ($nodename) = $sth->fetchrow_array();
     811    $html =~ s/\$\$NODENAME\$\$/$nodename/;
     812    $html =~ s/\$\$NODEID\$\$/$webvar{node}/;
     813  } else {
     814    $html =~ s/\$\$NODENAME\$\$//;
     815    $html =~ s/\$\$NODEID\$\$//;
     816  }
     817## end node hack
     818
    781819### gotta fix this in final
    782820  # Stick in customer info as necessary - if it's blank, it just ends
     
    841879  my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from},
    842880        $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
    843         $webvar{circid}, $webvar{privdata});
     881        $webvar{circid}, $webvar{privdata}, $webvar{node});
    844882
    845883  if ($code eq 'OK') {
     
    10061044      $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g;
    10071045    }
     1046## node hack
     1047  $sth = $ip_dbh->prepare("SELECT node_id FROM noderef WHERE block='$webvar{block}'");
     1048  $sth->execute;
     1049  my ($nodeid) = $sth->fetchrow_array();
     1050  if ($nodeid) {
     1051    $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     1052    $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1053    my $nodes = "<select name=node>\n";
     1054    while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1055      $nodes .= "<option".($nodeid == $nid ? ' selected' : '')." value='$nid'>$nname</option>\n";
     1056    }
     1057    $nodes .= "</select>\n";
     1058    $html =~ s/\$\$NODE\$\$/$nodes/;
     1059  } else {
     1060    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     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<option value=>--</option>\n";
     1064      while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1065        $nodes .= "<option value='$nid'>$nname</option>\n";
     1066      }
     1067      $nodes .= "</select>\n";
     1068      $html =~ s/\$\$NODE\$\$/$nodes/;
     1069    } else {
     1070      $html =~ s|\$\$NODE\$\$|N/A|;
     1071    }
     1072  }
     1073## end node hack
    10081074    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
    10091075    $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g;
     
    10121078    $html =~ s|\$\$NOTES\$\$|<textarea rows="8" cols="64" name="notes" class="regular">$data[6]</textarea>|g;
    10131079  } else {
     1080## node hack
     1081    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     1082      $sth = $ip_dbh->prepare("SELECT node_name FROM nodes INNER JOIN noderef".
     1083        " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'");
     1084      $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1085      my ($node) = $sth->fetchrow_array;
     1086      $html =~ s/\$\$NODE\$\$/$node/;
     1087    } else {
     1088      $html =~ s|\$\$NODE\$\$|N/A|;
     1089    }
     1090## end node hack
    10141091    $html =~ s/\$\$CUSTID\$\$/$data[1]/g;
    10151092    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
     
    11101187    $sth = $ip_dbh->prepare($sql);
    11111188    $sth->execute;
     1189## node hack
     1190    if ($webvar{node}) {
     1191      $ip_dbh->do("DELETE FROM noderef WHERE block='$webvar{block}'");
     1192      $sth = $ip_dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
     1193      $sth->execute($webvar{block},$webvar{node});
     1194    }
     1195## end node hack
    11121196    $ip_dbh->commit;
    11131197  };
Note: See TracChangeset for help on using the changeset viewer.