Changeset 466 for branches/htmlform
- Timestamp:
- 08/12/10 11:52:22 (14 years ago)
- Location:
- branches/htmlform
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/main.cgi
r465 r466 417 417 $sth = $ip_dbh->prepare("select city from routed where cidr='$master'"); 418 418 $sth->execute; 419 my @data = $sth->fetchrow_array; 420 421 print qq(<center><div class="heading">Summarizing allocated blocks for ). 422 qq($master ($data[0]):</div></center><br>\n); 423 424 startTable('CIDR allocation','Customer Location','Type','CustID','SWIPed?','Description/Name'); 419 my ($rcity) = $sth->fetchrow_array; 420 421 $page->param(master => "$master"); 422 $page->param(rcity => $rcity); 425 423 426 424 # Snag the allocations for this block … … 433 431 my $custsth = $ip_dbh->prepare("select count(*) from customers where custid=?"); 434 432 435 my $count=0; 436 while (my @data = $sth->fetchrow_array()) { 437 # cidr,city,type,custid,swip,description, as per the SELECT 438 my $cidr = new NetAddr::IP $data[0]; 439 440 # Clean up extra spaces that are borking things. 441 # $data[2] =~ s/\s+//g; 442 443 $custsth->execute($data[3]); 433 my $rowclass = 0; 434 my @blocklist; 435 while (my ($cidr,$city,$type,$custid,$swip,$desc) = $sth->fetchrow_array()) { 436 $custsth->execute($custid); 444 437 my ($ncust) = $custsth->fetchrow_array(); 445 438 446 # Prefix subblocks with "Sub " 447 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : ''). 448 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 449 $data[1], $disp_alloctypes{$data[2]}, $data[3], 450 ($data[4] eq 'y' ? ($ncust == 0 ? 'Yes<small>*</small>' : 'Yes') : 'No'), $data[5]); 451 # If the allocation is a pool, allow listing of the IPs in the pool. 452 if ($data[2] =~ /^.[pd]$/) { 453 $row[0] .= ' <a href="/ip/cgi-bin/main.cgi?action=listpool'. 454 "&pool=$data[0]\">List IPs</a>"; 455 } 456 457 printRow(\@row, 'color1') if ($count%2 == 0); 458 printRow(\@row, 'color2') if ($count%2 != 0); 459 $count++; 460 } 461 462 print "</table>\n"; 463 464 # If the routed block has no allocations, by definition it only has 465 # one free block, and therefore may be deleted. 466 if ($count == 0) { 467 print qq(<hr width="60%"><center><div class="heading">No allocations in ). 468 qq($master.</div></center>\n). 469 ($IPDBacl{$authuser} =~ /d/ ? 470 qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n). 471 qq(<input type=hidden name=action value="delete">\n). 472 qq(<input type=hidden name=block value="$master">\n). 473 qq(<input type=hidden name=alloctype value="rm">\n). 474 qq(<input type=submit value=" Remove this block ">\n). 475 qq(</form>\n) : 476 ''); 477 } 478 479 print qq(<hr width="60%">\n<center><div class="heading">Free blocks within routed ). 480 qq(submaster $master</div></center>\n); 481 482 startTable('CIDR block','Range'); 439 my %row = ( 440 rowclass => $rowclass++ % 2, 441 block => $cidr, 442 city => $city, 443 type => $disp_alloctypes{$type}, 444 custid => $custid, 445 swip => ($swip eq 'y' ? ($ncust == 0 ? 'Yes<small>*</small>' : 'Yes') : 'No'), 446 desc => $desc 447 ); 448 $row{subblock} = ($type =~ /^.r$/); # hmf. wonder why these won't work in the hash declaration... 449 $row{listpool} = ($type =~ /^.[pd]$/); 450 push (@blocklist, \%row); 451 } 452 $page->param(blocklist => \@blocklist); 453 454 $page->param(delrouted => $IPDBacl{$authuser} =~ /d/); 483 455 484 456 # Snag the free blocks. We don't really *need* to be pedantic about avoiding 485 457 # unrouted free blocks, but it's better to let the database do the work if we can. 486 $count = 0; 458 $rowclass = 0; 459 my @unassigned; 487 460 $sth = $ip_dbh->prepare("select cidr,routed from freeblocks where cidr <<= '$master'". 488 461 " order by cidr"); 489 462 $sth->execute(); 490 while (my @data = $sth->fetchrow_array()) { 491 # cidr,routed 492 my $cidr = new NetAddr::IP $data[0]; 493 # Include some HairyPerl(TM) to prefix subblocks with "Sub " 494 my @row = ((($data[1] ne 'y' && $data[1] ne 'n') ? 'Sub ' : ''). 495 ($IPDBacl{$authuser} =~ /a/ ? qq(<a href="/ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>) : $cidr), 496 $cidr->range); 497 printRow(\@row, 'color1') if ($count%2 == 0); 498 printRow(\@row, 'color2') if ($count%2 != 0); 499 $count++; 500 } 501 502 print "</table>\n"; 463 while (my ($cidr_db,$routed) = $sth->fetchrow_array()) { 464 my $cidr = new NetAddr::IP $cidr_db; 465 466 my %row = ( 467 rowclass => $rowclass++ % 2, 468 subblock => ($routed ne 'y' && $routed ne 'n'), 469 fblock => $cidr_db, 470 fbtype => $routed, 471 frange => $cidr->range, 472 ); 473 push @unassigned, \%row; 474 } 475 $page->param(unassigned => \@unassigned); 476 503 477 } # showRBlock 504 478 -
branches/htmlform/ipdb.css
r465 r466 85 85 a:active { color:#cc0000; } /* selected link */ 86 86 87 table.cent re{87 table.center { 88 88 margin-left: auto; 89 89 margin-right: auto; … … 97 97 } 98 98 tr.row0 { 99 background-color: # A8C4D0;99 background-color: #D0E0E0; 100 100 font-family: Verdana, Arial, Helvetica, sans-serif; 101 101 font-size: 90%; 102 102 } 103 103 tr.row1 { 104 background-color: # d0e0e0;104 background-color: #A8C4D0; 105 105 font-family: Verdana, Arial, Helvetica, sans-serif; 106 106 font-size: 90%; … … 110 110 width: 60%; 111 111 } 112 hr.w30 { 113 width: 30%; 114 } 112 115 113 116 /* legacy defs */ 114 tr.color0 {115 background-color: #A8C4D0;116 font-family: Verdana, Arial, Helvetica, sans-serif;117 font-size: 90%;118 }119 120 tr.color1 {121 background-color: #d0e0e0;122 font-family: Verdana, Arial, Helvetica, sans-serif;123 font-size: 90%;124 }125 126 tr.color2 {127 background-color: #A8C4D0;128 font-family: Verdana, Arial, Helvetica, sans-serif;129 font-size: 90%;130 }131 132 117 tr.hack { 133 118 background-color: #E4EEE8; -
branches/htmlform/templates/index.tmpl
r451 r466 1 1 <br> 2 2 <div class="center"> 3 <table class="cent re" width="98%" cellspacing="0">3 <table class="center" width="98%" cellspacing="0"> 4 4 <tr class="heading"> 5 5 <td>Master netblock</td> -
branches/htmlform/templates/showmaster.tmpl
r465 r466 3 3 4 4 <TMPL_IF routedlist> 5 <table class="cent re" width="98%" cellspacing="0">5 <table class="center" width="98%" cellspacing="0"> 6 6 <tr> 7 7 <td class="heading">Routed block</td> … … 23 23 </table> 24 24 <TMPL_ELSE> 25 <hr class="w 60">25 <hr class="w30"> 26 26 <div class="tbltitle">No allocations in <TMPL_VAR NAME=master>. 27 27 <TMPL_IF delmaster> … … 41 41 <br> 42 42 <hr class="w60"> 43 <br>44 43 45 44 <div class="tbltitle">Unrouted blocks in <TMPL_VAR NAME=master>:</div> … … 47 46 48 47 <TMPL_IF NAME=unrouted> 49 <table class="cent re" width="98%" cellspacing="0">48 <table class="center" width="98%" cellspacing="0"> 50 49 <tr> 51 50 <td class="heading">Netblock</td> … … 62 61 </table> 63 62 <TMPL_ELSE> 64 <hr class="w 60">63 <hr class="w30"> 65 64 <div class="tbltitle">No unrouted blocks in <TMPL_VAR NAME=master>.</div> 66 65 </TMPL_IF>
Note:
See TracChangeset
for help on using the changeset viewer.