Changeset 653 for trunk


Ignore:
Timestamp:
12/17/14 18:04:01 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Extend listSubs() to include some details on container blocks when
appropriate. Not sure this format will work; it ends up looking very
busy and confused after importing a dataset from IPDB 2.8. Consider
splitting containers vs direct allocations (so that there would be
three main page sections, not two).

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r652 r653  
    500500  my $custsth = $dbh->prepare("SELECT count(*) FROM customers WHERE custid = ?");
    501501
     502  # snag some more details
     503  my $substh = $dbh->prepare("SELECT count(*) FROM allocations WHERE cidr <<= ? AND type='rm' AND master_id = ? AND NOT cidr = ? ");
     504  my $alsth = $dbh->prepare("SELECT count(*) FROM allocations WHERE cidr <<= ? ".
     505        "AND NOT type='rm' AND NOT type='mm' AND master_id = ?");
     506  my $freesth = $dbh->prepare("SELECT count(*) FROM freeblocks WHERE cidr <<= ? AND master_id = ?");
     507  my $lfreesth = $dbh->prepare("SELECT masklen(cidr) AS maskbits FROM freeblocks WHERE cidr <<= ?".
     508        " AND master_id = ? ORDER BY masklen(cidr) LIMIT 1");
     509
    502510  my @blocklist;
    503   while (my ($cidr,$city,$type,$custid,$swip,$desc,$id) = $sth->fetchrow_array()) {
     511  while (my ($cidr,$city,$type,$custid,$swip,$desc,$id,$mid) = $sth->fetchrow_array()) {
    504512    $custsth->execute($custid);
    505513    my ($ncust) = $custsth->fetchrow_array();
     514    $substh->execute($cidr, $mid, $cidr);
     515    my ($cont) = $substh->fetchrow_array();
     516    $alsth->execute($cidr, $mid);
     517    my ($alloc) = $alsth->fetchrow_array();
     518    $freesth->execute($cidr, $mid);
     519    my ($free) = $freesth->fetchrow_array();
     520    $lfreesth->execute($cidr, $mid);
     521    my ($lfree) = $lfreesth->fetchrow_array();
     522    $lfree = "/$lfree" if $lfree;
     523    $lfree = '<NONE>' if !$lfree;
    506524    my %row = (
    507525        block => $cidr,
     526        subcontainers => $cont,
     527        suballocs => $alloc,
     528        subfree => $free,
     529        lfree => $lfree,
    508530        city => $city,
    509531        type => $disp_alloctypes{$type},
  • trunk/templates/showsubs.tmpl

    r627 r653  
    3131<td><TMPL_VAR NAME=desc></td>
    3232</tr>
     33<TMPL_IF hassubs>
     34<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
     35<td colspan=4>
     36Containers: <TMPL_VAR NAME=subcontainers>, Allocations: <TMPL_VAR NAME=suballocs>, Free: <TMPL_VAR NAME=subfree>, Largest free: <TMPL_VAR ESCAPE=HTML NAME=lfree>
     37</td><td colspan=2></td></tr>
     38</TMPL_IF>
    3339</TMPL_LOOP>
    3440</table>
Note: See TracChangeset for help on using the changeset viewer.