<%args> $pua_id $edit => 'f' $contact_id => -1 <%once> use DBI; Personal User Agent
  PUA Interface - Electronic Numbering System InternetNZ  
 

 
 
<& nav.html, pua_id => $pua_id, current_page => 'pua_contacts.html' &>

Contacts

<& _list_contacts, pua_id => $pua_id, contact_id => $contact_id &>

New contact record

Contact name:
Comment:
Contact uri
(individuals only):
Group member
(groups only):

Contact Details

% if ($edit eq 't') {
<& _get_contact_details, contact_id => $contact_id &>
% }

Group Members

<& _list_members, pua_id => $pua_id, contact_id => $contact_id &>

 
Powered by Catalyst IT
<%def _list_contacts> <%args> $pua_id $contact_id <%init> my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr; my $sth = $dbh->prepare("SELECT * from pua_contact WHERE pua_id=$pua_id ORDER BY contact_name, comment;"); $sth->execute or die "Execute failed: " . $sth->errstr; my $rv = ""; my @current; while (@current = $sth->fetchrow_array()) { if ($rv eq "") { print "\n"; } my $class = $current[0] == $contact_id ? ' class="active"' : ''; $rv .= " $current[2]"; $rv .= defined $current[3] && $current[3] ne '' ? " ($current[3])" : ''; $rv .= "\n"; $rv .= " [delete]\n"; $rv .= "\n"; } if ($rv eq "") { print "No contacts found.\n"; } else { print $rv; print "
\n"; } <%def _get_contact_details> <%args> $contact_id <%init> my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr; my $sth = $dbh->prepare("SELECT * from contact_method WHERE contact_id=$contact_id;"); $sth->execute or die "Execute failed: " . $sth->errstr; my $rv = ""; my @current; my $count = 1; while (@current = $sth->fetchrow_array()) { $rv .= "
\n"; $count++; } if ($rv eq '') { $rv .= "No contact methods available
"; } else { $rv .= " " . "
" . " "; } print $rv; <%def _list_members> <%args> $pua_id $contact_id <%init> my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr; my $sth = $dbh->prepare("SELECT c.contact_id, c.contact_name from pua_contact c, group_entry g WHERE c.contact_id=g.child_contact_id and g.parent_contact_id=$contact_id ORDER BY c.contact_name;"); $sth->execute or die "Execute failed: " . $sth->errstr; my @current; my $rv = ''; while (@current = $sth->fetchrow_array()) { if ($rv eq '') { $rv .= "\n"; } $rv .= " \n"; $rv .= " \n"; $rv .= " \n"; $rv .= " \n"; } if ($rv ne '') { $rv .= "
$current[1][delete]
\n"; $sth = $dbh->prepare("SELECT contact_id, contact_name from pua_contact where pua_id=$pua_id;"); $sth->execute or die "Execute failed: " . $sth->errstr; $rv .= "Contact:
"; } else { $rv = "No group members available
"; } print $rv; <%def _contact_options> <%args> $pua_id <%init> my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr; my $sth = $dbh->prepare("SELECT contact_id, contact_name from pua_contact where pua_id=$pua_id;"); $sth->execute or die "Execute failed: " . $sth->errstr; while (my @current = $sth->fetchrow_array()) { print ""; }