OSSP CVS Repository

ossp - Check-in [3415]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3415
Date: 2003-May-29 20:52:55 (local)
2003-May-29 18:52:55 (UTC)
User:rse
Branch:
Comment: fully work-off person select and detail areas after code restructuring
Tickets:
Inspections:
Files:
ossp-pkg/sdb/sdb.cgi      1.1 -> 1.2     319 inserted, 348 deleted

ossp-pkg/sdb/sdb.cgi 1.1 -> 1.2

--- sdb.cgi      2003/05/29 11:03:04     1.1
+++ sdb.cgi      2003/05/29 18:52:55     1.2
@@ -192,7 +192,7 @@
 #   open DB environment
 my $db;
 ($db = DBI->connect("dbi:SQLite:dbname=sdb.db", "", ""))
-    || die "unable to SQLite database sdb.db";
+    || die "unable to connect to SQLite database \"sdb.db\"";
 $db->{AutoCommit} = 1;
 $db->{RaiseError} = 1;
 
@@ -266,7 +266,6 @@
 ##  _________________________________________________________________________ 
 ##
 
-#   FIXME
 #   determine default UI display
 my $page = undef;
 foreach my $p (keys(%{$ui})) {
@@ -346,7 +345,8 @@
 $html >> q{page};
 
 #   generate page contents
-foreach my $page (sort(keys(%{$ui}))) {
+foreach my $page (@ui_pages) {
+    next if (not defined($ui->{$page}));
     if ($ui->{$page}->{-is} =~ m/^(visible|hidden)$/) {
         my $found = 0;
         foreach my $sub (
@@ -364,14 +364,15 @@
     }
 }
 
-#   insert html into output HTTP response body
+#   insert HTML into output HTTP response body
 $html->undivert(0);
 $body .= $html->string();
 
 #   optional debugging
+$body .= "<p/>\n";
 $body .= "<pre>\n";
 my @names = $cgi->param;
-foreach my $name (@names) {
+foreach my $name (sort(@names)) {
     my $value = $cgi->param($name);
     $body .= "  $name=\"$value\"\n";
 }
@@ -391,8 +392,8 @@
 sub ui_main_init {
     my ($my, $cgi, $db, $ui, $page) = @_;
 
-    $ui->{main}        = { -is => 'disable' };
-    $ui->{main}->{all} = { -is => 'disable' };
+    $ui->{main}        = { -is => 'disable', -with => 'default' };
+    $ui->{main}->{all} = { -is => 'disable', -with => 'default' };
 }
 
 sub ui_main_action {
@@ -440,19 +441,23 @@
 sub ui_person_init {
     my ($my, $cgi, $db, $ui, $page) = @_;
 
-    $ui->{person}           = { -is => 'disable' };
-    $ui->{person}->{select} = { -is => 'disable' };
-    $ui->{person}->{detail} = { -is => 'disable' };
-    $ui->{person}->{skill}  = { -is => 'disable' };
+    #   initialize person page
+    $ui->{person}           = { -is => 'disable', -with => 'default' };
+    $ui->{person}->{select} = { -is => 'disable', -with => 'default' };
+    $ui->{person}->{detail} = { -is => 'disable', -with => 'default' };
+    $ui->{person}->{skill}  = { -is => 'disable', -with => 'default' };
 }
 
 sub ui_person_action {
     my ($my, $cgi, $db, $ui, $page, $area, $elem) = @_;
 
+    #   recreate action string
+    my $action = "$page.$area.$elem";
+
     #   actions on select box
     if ($ui->{person}->{select}->{ADD}) {
         #   just open detail area for addition
-        $ui->{person}->{detail}->{id} = undef;
+        $ui->{person}->{detail}->{id}    = undef;
         $ui->{person}->{detail}->{-is}   = 'visible';
         $ui->{person}->{detail}->{-with} = 'add';
     }
@@ -572,98 +577,96 @@
     my $html = new String::Divert;
     $html->overload(1); 
 
-    if ($ui->{person}->{-is} eq 'visible') {
-        #   generate outer page CSS class
-        $html .= "<span class=\"person\">\n";
-        $html .= "  "; $html *= q{person};
-        $html .= "</span>\n";
-        $html >> q{person};
-
-        #   generate header
-        $html .= "<h2>Persons</h2>\n";
-        $html .= "<a href=\"$my->{URL}\">&larr; Back to Main Menu</a>";
-
-        #   generate page canvas
-        #   +-------+-------+
-        #   | area1 | area2 |
-        #   +-------+-------+
-        #   |     area3     |
-        #   +---------------+
-        $html .= "<p>\n";
-        $html .= "<table width=100%>\n";
-        $html .= "  <tr>\n";
-        $html .= "    <td valign=top class=\"box\" width=\"50%\">\n";
-        $html .= "      "; $html *= q{area1};
-        $html .= "    </td>\n";
-        $html .= "    <td>\n";
-        $html .= "      &nbsp;&nbsp;\n";
-        $html .= "    </td>\n";
-        $html .= "    <td valign=top class=\"box\" width=\"50%\">\n";
-        $html .= "      "; $html *= q{area2};
-        $html .= "    </td>\n";
-        $html .= "  </tr>\n";
-        $html .= "  <tr>\n";
-        $html .= "    <td colspan=3>\n";
-        $html .= "      &nbsp;\n";
-        $html .= "    </td>\n";
-        $html .= "  </tr>\n";
-        $html .= "  <tr>\n";
-        $html .= "    <td colspan=3 valign=top class=\"box\" width=\"100%\">\n";
-        $html .= "      "; $html *= q{area3};
-        $html .= "    </td>\n";
-        $html .= "  </tr>\n";
-        $html .= "</table>\n";
-    }
-    else {
-        $html *= q{area1};
-        $html *= q{area2};
-        $html *= q{area3};
-    }
+    #   filter output according to visibility
+    $html->storage(($ui->{person}->{-is} eq 'visible' ? 'all' : 'fold'));
 
+    #   generate outer page CSS class
+    $html .= "<span class=\"person\">\n";
+    $html .= "  " . $cgi->hidden(-name  => "person", -default => 1)."\n";
+    $html .= "  "; $html *= q{person};
+    $html .= "</span>\n";
+    $html >> q{person};
+
+    #   generate header
+    $html .= "<h2>Persons</h2>\n";
+    $html .= "<a href=\"$my->{URL}\">&larr; Back to Main Menu</a>";
+
+    #   generate page canvas
+    #   +-------+-------+
+    #   | area1 | area2 |
+    #   +-------+-------+
+    #   |     area3     |
+    #   +---------------+
+    $html .= "<p>\n";
+    $html .= "<table width=100%>\n";
+    $html .= "  <tr>\n";
+    $html .= "    <td valign=top class=\"box\" width=\"50%\">\n";
+    $html .= "      "; $html *= q{area1};
+    $html .= "    </td>\n";
+    $html .= "    <td>\n";
+    $html .= "      &nbsp;&nbsp;\n";
+    $html .= "    </td>\n";
+    $html .= "    <td valign=top class=\"box\" width=\"50%\">\n";
+    $html .= "      "; $html *= q{area2};
+    $html .= "    </td>\n";
+    $html .= "  </tr>\n";
+    $html .= "  <tr>\n";
+    $html .= "    <td colspan=3>\n";
+    $html .= "      &nbsp;\n";
+    $html .= "    </td>\n";
+    $html .= "  </tr>\n";
+    $html .= "  <tr>\n";
+    $html .= "    <td colspan=3 valign=top class=\"box\" width=\"100%\">\n";
+    $html .= "      "; $html *= q{area3};
+    $html .= "    </td>\n";
+    $html .= "  </tr>\n";
+    $html .= "</table>\n";
+
+    ##  _____________________________________________________________________
     ##
     ##  generate area: Person Selection
+    ##  _____________________________________________________________________
     ##
-    if ($ui->{person}->{-is} eq 'visible') {
-        #   force selection box to be always visible
-        #   if whole area is visible
-        $ui->{person}->{select}->{-is} = 'visible';
+
+    #   force selection box to be always visible if whole area is visible
+    $ui->{person}->{select}->{-is} = 'visible'
+        if ($ui->{person}->{-is} eq 'visible');
+
+    #   generate CSS class
+    $html >> q{area1};
+    $html .= "<span class=\"select\">\n";
+    $html .= "  "; $html *= q{select};
+    $html .= "</span>\n";
+    $html >> q{select};
+
+    #   generate inner header
+    $html .= "<h3>Select Person and Action</h3>\n";
+
+    #   generate inner canvas
+    $html .= "<table width=100%>\n";
+    $html .= "  <tr>\n";
+    $html .= "    <td width=100%>\n";
+    $html .= "      "; $html *= q{select-list};
+    $html .= "    </td>\n";
+    $html .= "    <td valign=top height=100%>\n";
+    $html .= "      "; $html *= q{select-buttons};
+    $html .= "    </td>\n";
+    $html .= "  </tr>\n";
+    $html .= "</table>\n";
+
+    #   generate the selection list widget
+    $html >> q{select-list};
+    my $rv = $db->selectall_arrayref(
+        "SELECT pe_id,pe_name FROM sdb_person ORDER BY pe_name;"
+    );
+    my $pe_values = [];
+    my $pe_labels = {};
+    foreach my $r (@{$rv}) {
+        push(@{$pe_values}, $r->[0]);
+        $pe_labels->{$r->[0]} = $r->[1];
     }
-    #$html->storage($ui->{person}->{select}->{-is} eq 'visible' ? 1 : 0);
+    my $pe_default = $ui->{person}->{select}->{id} || $pe_values->[0];
     if ($ui->{person}->{select}->{-is} eq 'visible') {
-        #   generate CSS class
-        $html >> q{area1};
-        $html .= "<span class=\"select\">\n";
-        $html .= "  "; $html *= q{select};
-        $html .= "</span>\n";
-        $html >> q{select};
-
-        #   generate inner header
-        $html .= "<h3>Select Person and Action</h3>\n";
-
-        #   generate inner canvas
-        $html .= "<table width=100%>\n";
-        $html .= "  <tr>\n";
-        $html .= "    <td width=100%>\n";
-        $html .= "      "; $html *= q{select-list};
-        $html .= "    </td>\n";
-        $html .= "    <td valign=top height=100%>\n";
-        $html .= "      "; $html *= q{select-buttons};
-        $html .= "    </td>\n";
-        $html .= "  </tr>\n";
-        $html .= "</table>\n";
-
-        #   generate the selection list widget
-        $html >> q{select-list};
-        my $rv = $db->selectall_arrayref(
-            "SELECT pe_id,pe_name FROM sdb_person ORDER BY pe_name;"
-        );
-        my $pe_values = [];
-        my $pe_labels = {};
-        foreach my $r (@{$rv}) {
-            push(@{$pe_values}, $r->[0]);
-            $pe_labels->{$r->[0]} = $r->[1];
-        }
-        my $pe_default = $ui->{person}->{select}->{id} || $pe_values->[0];
         if (@{$pe_values} > 0) {
             $html .= $cgi->scrolling_list(
                 -override  => 1,
@@ -675,87 +678,111 @@
                 -class     => 'id',
             ) . "\n";
         }
-        $html << q{select-list};
+    }
+    else {
+        $html .= $cgi->hidden(
+            -name    => 'person.select.id',
+            -default => $pe_default
+        );
+    }
+    $html << q{select-list};
 
-        #   generate the selection list attached buttons
-        $html >> "select-buttons";
+    #   generate the selection list attached buttons
+    $html >> "select-buttons";
+    $html .= $cgi->submit(
+        -name  => 'person.select.ADD', 
+        -value => 'Add Person &rarr;',
+        -class => 'ADD'
+    ) . "<br>";
+    if (@{$pe_values} > 0) {
         $html .= $cgi->submit(
-            -name  => 'person.select.ADD', 
-            -value => 'Add Person &rarr;',
-            -class => 'ADD'
-        ) . "<br>";
-        if (@{$pe_values} > 0) {
-            $html .= $cgi->submit(
-                -name  => 'person.select.VIEW',
-                -value => 'View Person &rarr;',
-                -class => 'VIEW'
-            ) . "<br/>";
-            $html .= $cgi->submit(
-                -name  => 'person.select.EDIT',
-                -value => "Edit Person &rarr;",
-                -class => "EDIT"
-            ) . "<br/>";
-            $html .= $cgi->submit(
-                -name  => 'person.select.DELETE',
-                -value => '&larr; Delete Person',
-                -class => 'DELETE'
-            ) . "<br/>";
-        }
-        $html << q{select-buttons};
+            -name  => 'person.select.VIEW',
+            -value => 'View Person &rarr;',
+            -class => 'VIEW'
+        ) . "<br/>";
+        $html .= $cgi->submit(
+            -name  => 'person.select.EDIT',
+            -value => "Edit Person &rarr;",
+            -class => "EDIT"
+        ) . "<br/>";
+        $html .= $cgi->submit(
+            -name  => 'person.select.DELETE',
+            -value => '&larr; Delete Person',
+            -class => 'DELETE'
+        ) . "<br/>";
+    }
+    $html << q{select-buttons};
+
+    #   undivert from select area
+    $html << q{area1};
+
+    ##  _____________________________________________________________________
+    ##
+    ##  generate area: Person Detail
+    ##  _____________________________________________________________________
+    ##
 
-        $html << q{area1};
+    #   generate CSS class
+    $html >> q{area2};
+    $html .= "<span class=\"detail\">\n";
+    $html .= "  "; $html *= q{detail};
+    $html .= "</span>\n";
+    $html >> q{detail};
+
+    #   generate inner header
+    my $action = $ui->{person}->{detail}->{-with};
+    $html .= "<h3>".uc(substr($action,0,1)).substr($action,1)." Person</h3>\n";
+    $html .= "<span class=\"$action\">\n";
+    $html .= "  "; $html *= q{detail-sub};
+    $html .= "</span>\n";
+    $html >> q{detail-sub};
+
+    #   generate inner canvas
+    $html .= "<table>\n";
+    $html .= "  "; $html *= q{detail-standard};
+    $html .= "  "; $html *= q{detail-membership};
+    $html .= "  "; $html *= q{detail-buttons};
+    $html .= "</table>\n";
+
+    #   fetch person details
+    my $pe = undef;
+    if ($action eq 'view' or $action eq 'edit') {
+        my $id = $ui->{person}->{select}->{id};
+        if ($id eq '') {
+            die "no person selected";
+        }
+        $pe = $db->selectrow_hashref(sprintf(
+            "SELECT pe_id AS id, pe_name AS name, pe_email AS email, pe_phone AS phone" .
+            "  FROM sdb_person WHERE pe_id = %s;",
+            &sql_escape($id)
+        ));
+        if (not defined($pe)) {
+            die "person with id \"$id\" not found";
+        }
     }
     else {
-        $html >> q{area1};
-        $html << q{area1};
+        $pe = { id => '', name => '', email => '', phone => '' };
     }
 
-    #   generate area: BEGIN PERSON DETAIL BOX
-    if ($ui->{person}->{detail}->{-is} eq 'visible') {
-        $html .= "<span class=\"detail\">";
-        #   determine content variant
-        my $action = $ui->{person}->{detail}->{-with};
-        $html .= "<h3>".uc(substr($action,0,1)).substr($action,1)." Person</h3>";
-        $html .= "<span class=\"$action\">";
-
-        #   fetch person details
-        my $pe = undef;
-        if ($action eq 'view' or $action eq 'edit') {
-            my $id = $ui->{person}->{select}->{id};
-            if ($id eq '') {
-                die "no person selected";
-            }
-            $pe = $db->selectrow_hashref(sprintf(
-                "SELECT pe_id AS id, pe_name AS name, pe_email AS email, pe_phone AS phone" .
-                "  FROM sdb_person WHERE pe_id = %s;",
-                &sql_escape($id)
-            ));
-            if (not defined($pe)) {
-                die "person with id \"$id\" not found";
-            }
+    #   display person details (standard)
+    $html >> q{detail-standard};
+    my $label = {
+        'name'  => 'Person Name',
+        'email' => 'Email Address',
+        'phone' => 'Phone Number'
+    };
+    my $i = 0;
+    foreach my $a (qw(name email phone)) {
+        $html .= "<tr class=\"row-$i\">\n";
+        $html .= "  <td class=\"label\">\n";
+        $html .= "    ".$label->{$a}.":";
+        $html .= "  </td>\n";
+        $html .= "  <td class=\"content\">\n";
+        if ($action eq 'view') {
+            $html .= $pe->{$a};
         }
         else {
-            $pe = { id => '', name => '', email => '', phone => '' };
-        }
-
-        #   display person details
-        $html .= "<table>\n";
-        my $label = {
-            'name'  => 'Person Name',
-            'email' => 'Email Address',
-            'phone' => 'Phone Number'
-        };
-        my $i = 0;
-        foreach my $a (qw(name email phone)) {
-            $html .= "  <tr class=\"row-$i\">\n";
-            $html .= "    <td class=\"label\">\n";
-            $html .= "      ".$label->{$a}.":";
-            $html .= "    </td>\n";
-            $html .= "    <td class=\"content\">\n";
-            if ($action eq 'view') {
-                $html .= $pe->{$a};
-            }
-            else {
+            if ($ui->{person}->{detail}->{-is} eq 'visible') {
                 $html .= $cgi->textfield(
                     -override  => 1,
                     -name      => "person.detail.$a",
@@ -764,198 +791,142 @@
                     -maxlength => 80
                 );
             }
-            $html .= "    </td>\n";
-            $html .= "  </tr>\n";
-            $i = ($i + 1) % 2;
-        }
-        $html .= "  <tr class=\"$row-$i\">\n";
-        $html .= "    <td valign=top class=\"label\">Team Membership:\n";
-        $html .= "    </td>\n";
-        $html .= "    <td class=\"content\">\n";
-        if ($action eq 'view') {
-            my $te_all = $db->selectcol_arrayref(sprintf(
-                "SELECT te_name FROM sdb_team,sdb_member" .
-                "  WHERE te_id = ms_te_id AND ms_pe_id = %s" .
-                "  ORDER BY te_name;",
-                &sql_escape($pe->{id})
-            ));
-            if (@{$te_all} == 0) {
-                $html .= "-none-";
-            }
-            else {
-                for (my $i = 0; $i < @{$te_all}; $i++) {
-                    my $te_name = $te_all->[$i];
-                    $html .= ", " if ($i != 0);
-                    $html .= $te_name;
-                }
-            }
-        }
-        else {
-            my $te_values = [];
-            my $te_labels = {};
-            my $te_all = $db->selectall_arrayref(
-                "SELECT te_id, te_name FROM sdb_team ORDER BY te_name;"
-            );
-            foreach my $r (@{$te_all}) {
-                push(@{$te_values}, $r->[0]);
-                $te_labels->{$r->[0]} = $r->[1];
-            }
-            my $te_defaults = [];
-            if ($action eq 'edit') {
-                $te_defaults = $db->selectcol_arrayref(sprintf(
-                    "SELECT ms_te_id FROM sdb_member WHERE ms_pe_id = %s;",
-                    &sql_escape($pe->{id})
-                ));
-            };
-            if (@{$te_values} == 0) {
-                $html .= "-none-";
-            }
             else {
-                $html .= $cgi->scrolling_list(
-                    -override => 1,
-                    -name     => 'person.detail.membership+',
-                    -values   => $te_values,
-                    -labels   => $te_labels,
-                    -default  => $te_defaults,
-                    -multiple => 'true',
-                    -size     => 10,
-                    -class    => 'membership',
+                $html .= $cgi->hidden(
+                    -name      => "person.detail.$a",
+                    -default   => $pe->{$a}
                 );
             }
         }
-        $html .= "    </td>\n";
-        $html .= "  </tr>\n";
-
-        $html .= "  <tr>\n";
-        $html .= "    <td></td>\n";
-        $html .= "    <td>\n";
-
-        $html .= "<table width=100%><tr>";
-        if ($action eq 'view') {
-            $html .= "<td>" . $cgi->submit(
-                -name  => 'person.detail.CLOSE',
-                -value => '&larr; Close',
-                -class => 'CLOSE'
-            ) . "</td>";
-            $html .= "<td>" . $cgi->submit(
-                -name  => 'person.detail.SKILL-VIEW',
-                -value => 'View Skills &darr;',
-                -class => 'SKILL-VIEW'
-            ) . "</td>";
-        }
-        else {
-            $html .= "<td>" . $cgi->submit(
-                -name  => 'person.detail.CANCEL',
-                -value => '&larr; Cancel',
-                -class => 'CANCEL'
-            ) . "</td>";
-            $html .= "<td>" . $cgi->submit(
-                -name  => 'person.detail.SAVE',
-                -value => '&uarr; Save',
-                -class => 'SAVE'
-            ) . "</td>";
-            $html .= "<td>" . $cgi->submit(
-                -name  => 'person.detail.SKILL-EDIT',
-                -value => 'Edit Skills &darr;',
-                -class => 'SKILL-EDIT'
-            ) . "</td>";
-        }
-        $html .= "</tr></table>";
-
-        $html .= "    </td>";
-        $html .= "  </tr>";
-        $html .= "</table>\n";
-        $html .= "</span>";
-        $html .= "</span>";
-    }
-    #   END PERSON DETAIL BOX
-
-    if ($edit eq 'rate' or $do eq 'view-skill') {
-        if ($edit eq 'rate') {
-            $html .= "<h3>Edit Skills</h3>";
+        $html .= "  </td>\n";
+        $html .= "</tr>\n";
+        $i = ($i + 1) % 2;
+    }
+    $html << q{detail-standard};
+
+    #   display person details (membership)
+    $html >> q{detail-membership};
+    $html .= "<tr class=\"$row-$i\">\n";
+    $html .= "  <td valign=top class=\"label\">\n";
+    $html .= "    Team Membership:\n";
+    $html .= "  </td>\n";
+    $html .= "  <td class=\"content\">\n";
+    $html .= "    "; $html *= q{detail-membership-sub};
+    $html .= "  </td>\n";
+    $html .= "</tr>\n";
+    $html >> q{detail-membership-sub};
+    if ($action eq 'view') {
+        my $te_all = $db->selectcol_arrayref(sprintf(
+            "SELECT te_name FROM sdb_team,sdb_member" .
+            "  WHERE te_id = ms_te_id AND ms_pe_id = %s" .
+            "  ORDER BY te_name;",
+            &sql_escape($pe->{id})
+        ));
+        if (@{$te_all} == 0) {
+            $html .= "-none-";
         }
         else {
-            $html .= "<h3>View Skills</h3>";
-        }
-
-        my $pe_id = $cgi->param('person.id');
-        if ($pe_id eq '') {
-            die "no person selected";
+            for (my $i = 0; $i < @{$te_all}; $i++) {
+                my $te_name = $te_all->[$i];
+                $html .= ", " if ($i != 0);
+                $html .= $te_name;
+            }
         }
-        my $rv = $db->selectall_arrayref(
-            "SELECT sk_id,sk_name" .
-            "  FROM sdb_skill " .
-            "  ORDER BY sk_name;"
-        );
-        my $deg = $db->selectall_hashref(
-            "SELECT sk_id,as_degree" .
-            "  FROM sdb_skill,sdb_provide" .
-            "  WHERE as_pe_id = '$pe_id' AND as_sk_id = sk_id;",
-            'sk_id'
+    }
+    else {
+        my $te_values = [];
+        my $te_labels = {};
+        my $te_all = $db->selectall_arrayref(
+            "SELECT te_id, te_name FROM sdb_team ORDER BY te_name;"
         );
-
-        $html .= "<table cellspacing=0 cellpadding=0>\n";
-        $html .= "<tr><td valign=top width=50%>";
-
-        $html .= "<table cellspacing=0 cellpadding=0>\n";
-        my $i = 0;
-        my $n = 0;
-        my $med = sprintf("%d", ($#{$rv}+1)/2);
-        $html .= $cgi->hidden(-name => 'rate.pe_id', -default => $pe_id);
-        foreach my $sk (@{$rv}) {
-            if ($n == $med) {
-                $html .= "</table>";
-                $html .= "</td>";
-                $html .= "<td>";
-                $html .= "&nbsp;&nbsp;";
-                $html .= "</td>";
-                $html .= "<td valign=top width=50%>";
-                $html .= "<table cellspacing=0 cellpadding=0>\n";
-            }
-            $html .= "<tr class=\"sdb-input-rate-$i\">\n";
-            $html .= "<td width=100%>\n";
-            $html .= $sk->[1]."&nbsp;&nbsp;";
-            $html .= "</td>\n";
-            $html .= "<td align=right>\n";
-            my $default = $deg->{$sk->[0]}->{as_degree} || 0;
-            my $labels = { 0 => 'unknown', 1 => 'beginner', 2 => 'intermediate', 3 => 'advanced', 4 => 'expert' };
-            if ($do eq 'view-skill') {
-                $html .= $labels->{$default};
-            }
-            else {
-                $html .= $cgi->scrolling_list(
-                    -name    => "rate.$sk->[0]",
-                    -values  => [ 0, 1, 2, 3, 4 ],
-                    -labels  => $labels,
-                    -default => $default,
-                    -size    => 1,
-                    -class   => "sdb-input-rate-$i",
-                    -style   => 'width: 100%;',
-                );
-            }
-            $html .= "</td>\n";
-            $html .= "</tr>\n";
-            $i = ($i + 1) % 2;
-            $n++;
-        }
-        $html .= "<tr><td colspan=2 align=right>\n";
-        $html .= "<table><tr>";
-        if ($do eq 'view-skill') {
-            $html .= "<td>".$cgi->submit(-name => 'do.close-skill', -value => "Close", -class => "sdb-button-view")."</td>";
+        foreach my $r (@{$te_all}) {
+            push(@{$te_values}, $r->[0]);
+            $te_labels->{$r->[0]} = $r->[1];
+        }
+        my $te_defaults = [];
+        if ($action eq 'edit') {
+            $te_defaults = $db->selectcol_arrayref(sprintf(
+                "SELECT ms_te_id FROM sdb_member WHERE ms_pe_id = %s;",
+                &sql_escape($pe->{id})
+            ));
+        };
+        if (@{$te_values} == 0) {
+            $html .= "-none-";
         }
         else {
-            $html .= "<td>".$cgi->submit(-name => 'rate.save', -value => "Save", -class => "sdb-button-save")."</td>";
-            $html .= "<td>".$cgi->submit(-name => 'rate.cancel', -value => "Cancel", -class => "sdb-button-cancel")."</td>";
+            $html .= $cgi->scrolling_list(
+                -override => 1,
+                -name     => 'person.detail.membership+',
+                -values   => $te_values,
+                -labels   => $te_labels,
+                -default  => $te_defaults,
+                -multiple => 'true',
+                -size     => 10,
+                -class    => 'membership',
+            );
         }
-        $html .= "</tr></table>";
-        $html .= "</td></tr>\n";
-        $html .= "</table>\n";
-
-        $html .= "</td></tr>\n";
-        $html .= "</table>\n";
+    }
+    $html << q{detail-membership};
 
+    #   generate attached buttons
+    $html >> q{detail-buttons};
+    $html .= "<tr>\n";
+    $html .= "  <td>\n";
+    $html .= "    &nbsp;";
+    $html .= "  </td>\n";
+    $html .= "  <td>\n";
+    $html .= "    "; $html *= q{detail-buttons-sub1};
+    $html .= "  </td>\n";
+    $html .= "</tr>\n";
+    $html >> q{detail-buttons-sub1};
+    $html .= "<table width=100%>\n";
+    $html .= "  <tr>\n";
+    $html .= "    "; $html *= q{detail-buttons-sub2};
+    $html .= "  </tr>\n";
+    $html .= "</table>\n";
+    $html >> q{detail-buttons-sub2};
+    if ($action eq 'view') {
+        $html .= "<td>" . $cgi->submit(
+            -name  => 'person.detail.CLOSE',
+            -value => '&larr; Close',
+            -class => 'CLOSE'
+        ) . "</td>";
+        $html .= "<td>" . $cgi->submit(
+            -name  => 'person.detail.SKILL-VIEW',
+            -value => 'View Skills &darr;',
+            -class => 'SKILL-VIEW'
+        ) . "</td>";
     }
+    else {
+        $html .= "<td>" . $cgi->submit(
+            -name  => 'person.detail.CANCEL',
+            -value => '&larr; Cancel',
+            -class => 'CANCEL'
+        ) . "</td>";
+        $html .= "<td>" . $cgi->submit(
+            -name  => 'person.detail.SAVE',
+            -value => '&uarr; Save',
+            -class => 'SAVE'
+        ) . "</td>";
+        $html .= "<td>" . $cgi->submit(
+            -name  => 'person.detail.SKILL-EDIT',
+            -value => 'Edit Skills &darr;',
+            -class => 'SKILL-EDIT'
+        ) . "</td>";
+    }
+    $html << q{detail-buttons};
+    
+    #   undivert from detail area
+    $html << q{area2};
 
+    ##  _____________________________________________________________________
+    ##
+    ##  generate area: Person Rating
+    ##  _____________________________________________________________________
+    ##
+
+    #   return unfolded HTML
     $html->undivert(0);
     return $html->string();
 }
+

CVSTrac 2.0.1