#!/usr/bin/perl

use DBI;
$dbh = DBI->connect("DBI:mysql:database=discardItems;host=localhost","username","password") or error_exit($DBI::errstr);

$select = $dbh->prepare("select oclc from removeOCLCholdings");
$select->execute();
while (@result = $select->fetchrow()) {
    $oclc = $result[0];
    $sansPrefix = $oclc;
    for ($x = 1; $x <= 3; $x++) {
        $sansPrefix =~ s/^[a-z]//;
    }
    $textarea .= "$sansPrefix\n";
}
$select->finish();

$dbh->disconnect();

$html = qq[
  <html>
  <head>
  <link rel="shortcut icon" type="image/png" href="https://folio.drew.edu/busybee.png">
  
 <style type="text/css">
  body {font-family: verdana, arial, sans-serif;}
  a:active {text-decoration: none; color: #f3654e;}
  a:link {text-decoration: none; color: #f3654e;}
  a:visited {text-decoration: none; color: #f3654e;}
  a:hover {text-decoration: none; color: #000000; background: #f3654e;}
  a.rusure:active {text-decoration: none; color: #cc1242;}
  a.rusure:link {text-decoration: none; color: #cc1242;}
  a.rusure:visited {text-decoration: none; color: #cc1242;}
  a.rusure:hover {text-decoration: none; color: #ffffff; background: #cc1242;}
  .v12 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;color:#ffffff;}
  .v18 {font-size: 18px; font-family: Verdana, Arial, Helvetica, sans-serif;color:#ffffff;}
  .v24 {font-size: 24px; font-family: Verdana, Arial, Helvetica, sans-serif;color:#ffffff;}
  input[type=button], input[type=submit], input[type=reset] {
   background-color: #f3654e;
   border: none;
   color: white;
   padding: 16px 32px;
   text-decoration: none;
   margin: 4px 2px;
   cursor: pointer;
  }
  </style>
  <title>remove OCLC holdings</title>
  </head>

  <body bgcolor="#000000" onLoad="document.theForm.OCLC.select()"><table border="0" width="100%" height="100%">
  <tr><th></th><th class="v24">folio.drew.edu | bibServices | discard items | remove OCLC holdings</th><th></th></tr>
  <tr><th></th><th class="v24">&nbsp;</th><th></th></tr>
  <tr><th></th><th class="v18">
    <p align="center"><table border="0"><tr><td class="v18"><form name="theForm"><textarea cols="120" name="OCLC" rows="20">$textarea</textarea></form> 
    <p align="center">Ctrl-C to copy this list of OCLC numbers...then...
    </td></tr></table>
    <a href="deleteFromMySQL.pl">OCLC holdings have been removed!</a>
  </th><th></th></tr>
  <tr>
   <th align="left" valign="bottom"><img border="0" src="https://folio.drew.edu/busybee.png">>
   <th>&nbsp;</th><th align="right" valign="bottom"><img width="200" src="https://folio.drew.edu/faith.jpg">>
  </tr>
  </table>
  </body>
  </html>
];

print qq[Content-Type: text/html \n\n $html ];