Advertisement
GregLeblanc

Untitled

Oct 29th, 2024
57
0
348 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.72 KB | None | 0 0
  1. <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  2. <html>
  3. <style>
  4. DIV#header {position: absolute; top: 0; bottom: 90%; left: 0; right: 0;
  5.             background: #00d0a0; margin-bottom: 0px;
  6.             border-style: solid; }
  7. DIV#main {position: absolute; top: 10%; bottom: 0; left: 0; right: 0;
  8.             overflow: scroll; background: white; margin-left: 4px;
  9.             padding: 10px; font-family: Times, serif; font-size: large; }
  10. P { font: Helvetica; font-size: large; }
  11. </style>
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  14. <meta name="GENERATOR" content="Mozilla/4.51 [en] (X11; I; Linux 2.2.5-15 i68 6) [Netscape]">
  15. <title>OUAL Operator Training Information</title>
  16. </head>
  17. <body>
  18. <DIV ID="header">
  19. <CENTER><font color=black><H1>OUAL Operator Training Information</h1></font></CENTER>
  20. </DIV>
  21. <DIV ID="main">
  22. <H2>List Operator Training Certifications</H2>
  23. <?php
  24.     global $_SERVER, $_GET;
  25.     if ( array_key_exists('REMOTE_ADDR',$_SERVER) ) {
  26.         echo "Connection from IP address ";
  27.             echo $_SERVER['REMOTE_ADDR'];
  28.     } else {
  29.         echo "Connection information not available";
  30.     }
  31.     if ( array_key_exists('REMOTE_HOST',$_SERVER) ) {
  32.             echo " (" . $_SERVER['REMOTE_HOST'] . ")";
  33.     }
  34.         echo "<br>Time: ";
  35.         echo date("Y M d   G:i:s");
  36.     echo '<BR>Logged in as ' . $_SERVER['REMOTE_USER'] . '<BR>';
  37. ?>
  38. <FORM METHOD=POST ACTION="https://edwards2.phy.ohio.edu/~oual/operators/training/optrain.php">
  39. <BUTTON TYPE=SUBMIT NAME="BACK" VALUE="BACK">Back to Operator Training Page</BUTTON>
  40. </FORM>
  41. <FORM METHOD=POST ACTION="https://edwards2.phy.ohio.edu/~oual/operators/training/optrainlist.php">Sort for:
  42. <BUTTON TYPE=SUBMIT NAME="SORTBY" VALUE="ascending">Oldest first</BUTTON>
  43. <BUTTON TYPE=SUBMIT NAME="SORTBY" VALUE="descending">Most recent first</BUTTON>
  44. <BUTTON TYPE=SUBMIT NAME="SORTBY" VALUE="name">Operator</BUTTON>
  45. <BUTTON TYPE=SUBMIT NAME="SORTBY" VALUE="certification">Certification</BUTTON>
  46. <BUTTON TYPE=SUBMIT NAME="SORTBY" VALUE="expire">Expiration date</BUTTON>
  47. <BUTTON TYPE=SUBMIT NAME="SORTBY" VALUE="status">Status</BUTTON>
  48. <?php
  49.     echo '<BR><INPUT TYPE=CHECKBOX NAME="NOKH" VALUE="nokh"';
  50.     if (array_key_exists('NOKH',$_POST)) echo ' CHECKED="checked"';
  51.     echo '>Do not show keyholder</INPUT>';
  52.     echo '<BR><INPUT TYPE=CHECKBOX NAME="NOOP" VALUE="noop"';
  53.     if (array_key_exists('NOOP',$_POST)) echo ' CHECKED="checked"';
  54.     echo '>Do not show operator levels</INPUT></FORM>';
  55.         // echo "<H3>Logged in as $_SERVER[\'REMOTE_USER\']</H3>";
  56.     // var_dump($_POST);
  57.         // echo "<br>";
  58.     require_once('DB.php');
  59.     $db = DB::connect("mysql://something:soomething@localhost/tandem");
  60.     IF ( DB::isError($db) ) {
  61.         echo "<font color=red>";
  62.         echo DB::errorMessage($db->code);
  63.         echo "</font><br>";
  64.         die( DB::errorMessage($db->code));
  65.     }
  66.     // echo "Connected to database<BR>";
  67. // ---------------------------------------
  68. function make_op_table() {
  69.     global $db,$op_name,$op_fname,$op_id,$op_status;
  70.     $sql = 'SELECT seq_nmbr,name,fname,status FROM operators;';
  71.     // echo "<BR> Get op nmbr sql is '$sql'<BR>";
  72.     $q = $db->query($sql);
  73.     IF ( DB::isError($db) ) {
  74.         echo "<font color=red>";
  75.         echo DB::errorMessage($db->code);
  76.         echo "</font><br>";
  77.         die( DB::errorMessage($db->code));
  78.     }
  79.     while ($opid = $q->fetchRow()) {
  80.         // echo "<BR> OpId result is <BR>"; var_dump($opid);
  81.         $op_id[$opid[1]] = $opid[0];    // Ptr by name
  82.         $op_name[$opid[0]] = $opid[1];  // Name by ptr
  83.         $op_fname[$opid[0]] = $opid[2]; // Fullname by ptr
  84.         $op_status[$opid[0]] = $opid[3];    // Status by ptr
  85.     }
  86.     // var_dump($op_id);
  87.     // var_dump($op_name);
  88. }
  89. // ---------------------------------------
  90. function make_cert_table() {
  91.     global $db,$tlist,$cert_name,$cert_id,$_SERVER;
  92.     $sql = 'SELECT seq_nmbr,certification FROM certifications ORDER BY certification;';
  93.     // echo "<BR> Get cert nmbr sql is '$sql'<BR>";
  94.     $q = $db->query($sql);
  95.     IF ( DB::isError($db) ) {
  96.         echo "<font color=red>";
  97.         echo DB::errorMessage($db->code);
  98.         echo "</font><br>";
  99.         die( DB::errorMessage($db->code));
  100.     }
  101.     while ($row = $q->fetchRow()) {
  102.         IF ( DB::isError($db) ) {
  103.             echo "<font color=red>";
  104.             echo DB::errorMessage($db->code);
  105.             echo "</font><br>";
  106.             die( DB::errorMessage($db->code));
  107.         }
  108.         $cert_id[$row[1]] = $row[0];    // Ptr by certification
  109.         $cert_name[$row[0]] = $row[1];  // Certification by ptr
  110.     }
  111.     // var_dump($cert_id);
  112.     // var_dump($cert_name);
  113. }
  114. // ---------------------------------------
  115. function make_train_table() {
  116.     global $db,$tlist,$tc_op,$tc_opf,$tc_cert,$tc_date,$tc_tr,$tc_stat;
  117.     global $op_name,$op_fname,$cert_name;
  118.     global $tc_expire,$tc_id,$_SERVER;
  119.     $sql = 'SELECT * FROM optraining ORDER BY entered DESC;';
  120.     $q = $db->query($sql);
  121.     IF ( DB::isError($db) ) {
  122.         echo "<font color=red>";
  123.         echo DB::errorMessage($db->code);
  124.         echo "</font><br>";
  125.         die( DB::errorMessage($db->code));
  126.     }
  127.     while ($row = $q->fetchRow()) {
  128.         IF ( DB::isError($db) ) {
  129.             echo "<font color=red>";
  130.             echo DB::errorMessage($db->code);
  131.             echo "</font><br>";
  132.             die( DB::errorMessage($db->code));
  133.         }
  134.         $tc_op[$row[0]] = $op_name[$row[1]];    // Name
  135.         $tc_opf[$row[0]] = $op_fname[$row[1]];  // Full name
  136.         $tc_cert[$row[0]] = $cert_name[$row[2]];// Certification
  137.         $tc_tr[$row[0]] = $op_name[$row[3]];    // Trainer name
  138.         $tc_stat[$row[0]] = $row[4];        // Status
  139.         $tc_date[$row[0]] = $row[5];        // Entered date
  140.         $tc_expire[$row[0]] = $row[6];      // Expire date
  141.     }
  142. }       // end of make_train_table(_) function
  143. // ---------------------------------------
  144.     make_op_table();
  145.     make_cert_table();
  146.     make_train_table();
  147.     //
  148.     // See if the user wants to sort the list
  149.     $sortby = 'ascending';  // What order is wanted
  150.     if (array_key_exists('SORTBY',$_POST)) {
  151.         $sortby = $_POST['SORTBY'];
  152.     }
  153.     switch ($sortby) {
  154.     case 'ascending':   // Oldest record first
  155.         array_multisort($tc_date,SORT_ASC,$tc_op,$tc_opf,$tc_cert,
  156.                     $tc_tr,$tc_stat,$tc_expire);
  157.         break;
  158.     default:
  159.     case 'descending':  // Most recent first
  160.         array_multisort($tc_date,SORT_DESC,$tc_op,$tc_opf,$tc_cert,
  161.                     $tc_tr,$tc_stat,$tc_expire);
  162.         break;
  163.     case 'name':        // Operator Name
  164.         array_multisort($tc_op,SORT_ASC,$tc_opf,$tc_cert,
  165.                     $tc_date,$tc_tr,$tc_stat,$tc_expire);
  166.         break;
  167.     case 'certification':   // Certification
  168.         array_multisort($tc_cert,SORT_ASC,$tc_op,$tc_opf,
  169.                     $tc_date,$tc_tr,$tc_stat,$tc_expire);
  170.         break;
  171.     case 'expire':      // Expiration date
  172.         array_multisort($tc_expire,SORT_DESC,$tc_op,SORT_ASC,$tc_opf,$tc_cert,
  173.                     $tc_date,$tc_tr,$tc_stat);
  174.         break;
  175.     case 'status':      // Certification status
  176.         array_multisort($tc_stat,SORT_DESC,$tc_op,SORT_ASC,$tc_opf,$tc_cert,
  177.                     $tc_date,$tc_tr,$tc_expire);
  178.         break;
  179.     }  
  180.     // Colors from the X11 rgb.txt database (sorry about the names...)
  181.     $color1 = "LEMONCHIFFON";
  182.     $color2 = "HONEYDEW";
  183.     $bgcolor = $color1;
  184.     echo '<TABLE CELLSPACING=10>';
  185.     echo "<TH>Operator<TH>Certification<TH>Date Entered<TH>Trained By";
  186.     echo "<TH>Status<TH>Expires<TR>";
  187.     $last_name = "";
  188.     foreach ( $tc_op as $seqid => $name ) {
  189.         if (array_key_exists('NOKH',$_POST) &&
  190.                 $tc_cert[$seqid] == 'Keyholder') continue;
  191.         if (array_key_exists('NOOP',$_POST) &&
  192.                 $tc_cert[$seqid] == 'Operator 1') continue;
  193.         if (array_key_exists('NOOP',$_POST) &&
  194.                 $tc_cert[$seqid] == 'Operator 2') continue;
  195.         if ( $name != $last_name ) {
  196.             if ($bgcolor==$color1) {
  197.                 $bgcolor=$color2;
  198.             } else {
  199.                 $bgcolor=$color1;
  200.             }
  201.         }
  202.         $last_name = $name;
  203.         echo "<TR BGCOLOR=$bgcolor>";
  204.         echo "<TD ALIGN=RIGHT>" . $tc_opf[$seqid] . "</TD>";
  205.         switch($tc_cert[$seqid]) {
  206.         case 'Keyholder':
  207.             $STCOLOR = 'MAROON';
  208.             break;
  209.         case 'Operator 1':
  210.             $STCOLOR = 'DARKORANGE'; // Yellow doesn't show up well
  211.             break;
  212.         case 'Operator 2':
  213.             $STCOLOR = 'GREEN'; // Yellow doesn't show up well
  214.             break;
  215.         default:
  216.             $STCOLOR = 'BLACK';
  217.         }
  218.         echo "<TD ALIGN=CENTER><FONT COLOR={$STCOLOR}> ";
  219.         echo $tc_cert[$seqid] . '</FONT></TD>';
  220.         echo "<TD ALIGN=CENTER>" . substr($tc_date[$seqid],0,10) . "</TD>";
  221.         echo "<TD ALIGN=CENTER>" . $tc_tr[$seqid] . "</TD>";
  222.         switch($tc_stat[$seqid]) {
  223.         case 'Active':
  224.             $STCOLOR = 'GREEN';
  225.             break;
  226.         case 'Pending':
  227.             $STCOLOR = 'ORANGE'; // Yellow doesn't show up well
  228.             break;
  229.         default:
  230.             $STCOLOR = 'RED';
  231.         }
  232.         echo "<TD ALIGN=CENTER><FONT COLOR={$STCOLOR}> ";
  233.         echo $tc_stat[$seqid] . '</FONT></TD>';
  234.         if ( $tc_expire[$seqid] == "") {
  235.             $expstring = "<FONT COLOR=GREY>(N/A)</FONT>";
  236.         } else {
  237.             $expstring = substr($tc_stat[$seqid],0,10);
  238.         }
  239.         echo "<TD ALIGN=CENTER>" . $expstring . "</TD>";
  240.         echo "</TR>";
  241.     }
  242.     echo '</TABLE>';
  243. ?>
  244. <FORM METHOD=POST ACTION="http://edwards2.phy.ohio.edu/~oual/operators/training/optrain.php">
  245. <BUTTON TYPE=SUBMIT NAME="BACK" VALUE="BACK">Back to Operator Training Page</BUTTON>
  246. </FORM>
  247. </DIV>
  248. </HTML>
  249.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement