Changeset 709 for trunk


Ignore:
Timestamp:
03/20/15 15:14:06 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Add a "delete" button for the admin tools SWIP customer editor. This
hack has finally hung around long enough to need one...

Location:
trunk
Files:
3 edited

Legend:

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

    r708 r709  
    236236} elsif ($webvar{action} eq 'listcust') {
    237237
    238   $sth = $ip_dbh->prepare("select custid,name,tech_handle from customers order by custid");
    239   $sth->execute;
    240   my @custlist;
    241   while (my @data = $sth->fetchrow_array) {
    242     my %row = (
    243         custid => $data[0],
    244         custname => $data[1],
    245         tech => $data[2]
    246         );
    247     push @custlist, \%row;
    248   }
    249   $page->param(custlist => \@custlist);
     238  my $clist = $ip_dbh->selectall_arrayref("SELECT custid,name AS custname,tech_handle AS tech ".
     239        "FROM customers ORDER BY custid", { Slice => {} } );
     240  $page->param(custlist => $clist);
    250241
    251242} elsif ($webvar{action} eq 'edcust') {
     
    279270} elsif ($webvar{action} eq 'updcust') {
    280271
    281   $sth = $ip_dbh->prepare("UPDATE customers SET".
    282         " name=?, street=?, city=?, province=?, country=?, pocode=?,".
    283         " phone=?, tech_handle=?, abuse_handle=?, admin_handle=?, special=?".
    284         " WHERE custid=?");
    285   $sth->execute($webvar{name}, $webvar{street}, $webvar{city}, $webvar{province},
    286         $webvar{country}, $webvar{pocode}, $webvar{phone}, $webvar{tech_handle},
    287         $webvar{abuse_handle}, $webvar{admin_handle}, $webvar{special}, $webvar{custid});
     272  if ($webvar{abutton} eq 'Update') {
     273    $ip_dbh->do(q(
     274        UPDATE customers
     275        SET name = ?, street = ?, city = ?, province=?, country=?, pocode=?,
     276        phone = ?, tech_handle = ?, abuse_handle = ?, admin_handle = ?, special = ?
     277        WHERE custid = ?
     278        ), undef,
     279        ($webvar{name}, $webvar{street}, $webvar{city}, $webvar{province}, $webvar{country}, $webvar{pocode},
     280        $webvar{phone}, $webvar{tech_handle}, $webvar{abuse_handle}, $webvar{admin_handle}, $webvar{special},
     281        $webvar{custid})
     282        );
     283    $page->param(whatact => "Updated");
     284  } elsif ($webvar{abutton} eq 'Delete (immediate)') {
     285    $ip_dbh->do("DELETE FROM customers WHERE custid = ?", undef, $webvar{custid});
     286    $page->param(whatact => "Deleted");
     287  } else {
     288    # Your llama is on fire
     289  }
     290  # Show what we've just either updated or deleted.
     291  # Deleted, so that in case of "OOOPS!!", the "special" data can be recovered.
    288292  $page->param(
    289293        custid => $webvar{custid},
  • trunk/templates/admin/edcust.tmpl

    r517 r709  
    2323<td>"Special":</td><td><textarea name="special" rows="4" cols="50"><TMPL_VAR NAME=special></textarea></td>
    2424</tr>
    25 <tr><td colspan="4" align="center"><input type="submit" value="Update"></td></tr>
     25<tr>
     26<td colspan="2" align="center"><input type="submit" name="abutton" value="Update"></td>
     27<td colspan="2" align="center"><input type="submit" name="abutton" value="Delete (immediate)"></td>
     28</tr>
    2629</table>
    2730</fieldset></form>
  • trunk/templates/admin/updcust.tmpl

    r517 r709  
    1 Updated <TMPL_VAR NAME=custid><br>
     1<TMPL_VAR NAME=whatact> <TMPL_VAR NAME=custid><br>
    22<table border=1>
    33<tr><td>CustID:</td><td><TMPL_VAR NAME=custid></td></tr>
Note: See TracChangeset for help on using the changeset viewer.