Location: PHPKode > projects > phpHamLog > phphamlog/logentry.php
<?php
/***************************************************************************

       phpHamLog

       $Id: logentry.php,v 1.2 2006/04/29 02:53:53 kc9aop Exp $

       Logentry

       Copyright (C) 2005 KC9AOP

       Portions Copyright (c) 2001 The phpBB Group

       This program is free software; you can redistributed it and/or
       modify it under the terms of the GNU General Public License
       as published by the Free Software Foundation; version 2 of the 
       License, or (at your option) any later version.

       This program is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       GNU General Public License for more details.

       You should have received a copy of the GNU General Public License
       along with this program; if not, write to the Free Software
       Foundation, Inc., 59 Temple Place - Suite 300, Boston, MA 02111-1307 USA.

 This is the entry screen for the log book. It is suggested you use this as
 a template for any input screens you make for different contests since
 all the fields are already here.

 10/18/01 - HTML cleanup, some fields now auto-uppercase or auto-capitalize.
            QSO end time defaults to start time if not specified.  Added QRZ
            lookup.
 10/20/01 - Auto-entry of start and end times if not filled in by user.  Uses 
            $utctime in configure.php to tell if logging UTC or local time 
            (who does?)
 04/17/06 - General reformat and cleanup.  Reorganize screen layout, install
            style sheet and add fill button for on and off times.

 ***************************************************************************/

#include ("configure.php");
include ("auth.php");

#######################################################
#  Convert frequency into common name bands  N4FWD
#######################################################
function arrl_band ( $afrequency, &$arrlband ) {
#######################################################
# Note: $arrlband variable is a "pass by reference" variable
# All assignments to $arrlband are automatically passed back to page
#######################################################
/* change frequency from char to float */
	$dband = (double)$afrequency;
	$thousand = 1000.0;
  	if ($dband < $thousand) 
  		$dband *= $thousand ;
	if (($dband >= 1800.0) && ($dband <= 2000.0) ) {
		$arrlband = "160M";
	} elseif ($dband >= 3500.0 && $dband <= 4000.0 ) {
		$arrlband = "80M";
	} elseif ($dband >= 7000.0 && $dband <= 7300.0 ) {
		$arrlband = "40M";
	} elseif ($dband >= 14000.0 && $dband <= 14350.0 ) {
		$arrlband = "20M";
	} elseif ($dband >= 21000.0 && $dband <= 21450.0 ) {
		$arrlband = "15M";
	} elseif ($dband >= 28000.0 && $dband <= 29700.0 ) {
		$arrlband = "10M";
	} elseif ($dband >= 50000.0 && $dband <= 54000.0 ) {
		$arrlband = "6M";
	} elseif ($dband >= 144000.0 && $dband <= 148000.0 ) {
		$arrlband = "2M";
	} elseif ($dband >= 222000.0 && $dband <= 225000.0 ) {
		$arrlband = "220MZ";
	} elseif ($dband >= 420000.0 && $dband <= 450000.0 ) {
		$arrlband = "440MZ";
	} elseif ($dband >= 902000.0 && $dband <= 928000.0 ) {
		$arrlband = "900MZ";
	} else
		$arrlband = "NULL";
}

#if the user is not logged in, kick them out
$loggedin = false;

session_start();
$result = session_is_registered("logcallid");

switch ($program) {
	case "FIELDDAY":
		if ($result) {
			$tmpcall = $HTTP_SESSION_VARS["logcallid"];
			$sql = "SELECT logcallid, storage FROM cookies WHERE logcallid = '$tmpcall' ";
			$result = mysql_query ($sql, $db)
  				or error_die ("Could not get 'cookies' data from database");
			$myrow = mysql_fetch_array($result);
		}
		break;
	default:
		$sql = "SELECT storage FROM cookies WHERE storeid = '1' ";	
		$result = mysql_query ($sql, $db)
  			or error_die ("Could not check cookie data in database");
		$myrow = mysql_fetch_array($result);
}

switch ($myrow[storage]) {
	case 'Y':
		$loggedin = TRUE;
		break;
	default:
		$loggedin = FALSE;
}

if ($loggedin == false) {
	header("Location: index.php");
}


# user hits the cancel button, so send them back to the main page
if ($cancel) {
	header("Location: index.php");
}

if ($logout) {
	header("Location: logout.php");
}

if ($ton)  {
               $note_msg = "Start Time set";

               if ($utctime != "N") {
                    $time = gmdate("H:i:s");
                    $timeoff = $time;
               }
               else {
                    $time = date("H:i:s");
                    $timeoff = $time;
               }

}

if ($toff)  {
               $note_msg = "End Time set";

               if ($utctime != "N")
                    $timeoff = gmdate("H:i:s");
               else
                    $timeoff = date("H:i:s");

}
        
        
# user hits the submit button, so save the data and give them an updated page
if ($submit) {
switch ($program) {
	case "FIELDDAY":
		if (strlen($time) == 0)
			$time = date("H:i");
		break;
	default:
  		if (strlen($time) == 0)
    		 {
        		if ($utctime != "N") 
             			$time = gmdate("H:i:s");
        		else
             			$time = date("H:i:s");
     		}
     
  		if (strlen($time) < 5)
     		{
       			$time = $time."00";
     		}
  		if (strlen($timeoff == 0))
     			$timeoff = $time;
  		if (strlen($timeoff) < 5)
     			$timeoff = $timeoff."00";
}

  $callsign = strtoupper($callsign);
  $date = date("Y-m-d",strtotime($date));
  
###############################################################################################################
# For Field Day logging - submit /   the FD version is a bit complicated since duplication checking is necessary!  N4FWD
###############################################################################################################
switch ($program) {
	case "FIELDDAY":
		$nonduplication = TRUE;
  		$exchange = strtoupper($exchange);
  		$arrlsec = strtoupper($arrlsec);
	/* look for dups N4FWD*/
  		$sql = "SELECT qsoid, mycall, frequency, mode, date, time, callsign, exchange, arrlsec FROM fdqso WHERE callsign = '$callsign' ";
  		$result = mysql_query($sql, $db)
      			or error_die("<font size=+1>An error occured<hr>Could not connect to the QSO database. $sql");
  		$myrow = mysql_fetch_array($result);

  		arrl_band($myrow[frequency],$storedband); // $storedband is modified by function
		arrl_band($frequency,$newband);
		
	/* checking for a match on 3 items N4FWD */
  		if (strcmp($myrow[callsign],$callsign) == 0 && strcmp($storedband,$newband) == 0 && strcmp($mode,$myrow[mode]) == 0 ) {
 			echo "<br><br>Duplicate Entry! Match on Callsign, Band, and Mode!<br>\n";
 			$nonduplication = FALSE;
	/* not a dup, insert into DB */
		} else {
  			$sql = "INSERT INTO fdqso (mycall, frequency, mode, date, time, callsign,
  				exchange, arrlsec) VALUES ('$tmpcall', '$frequency', '$mode', '$date', '$time', '$callsign', '$exchange', '$arrlsec')";
  			$result = mysql_query ($sql, $db)
  				or error_die ("Could not add QSO data to database");
  		}
		break;
	default:
		$city = ucwords ($city);
		$name = ucwords ($name);
		if ($qslsent == "on") $qslsent = "Y";
		if ($qslreceived == "on") $qslreceived = "Y";  
		$sql = "INSERT INTO qso (mycall, date, time, frequency, mode, power, callsign, rstsent, rstreceived, timeoff, city, state, 
  		      name, comments, qslsent, qslreceived) VALUES ('$mycall', '$date', '$time', '$frequency', '$mode', '$power',
   		     '$callsign', '$rsent', '$rreceived', '$timeoff', '$city', '$spc', '$name', '$comments', '$qslsent', '$qslreceived')";
   		   $result = mysql_query ($sql, $db)
  			or error_die ("Could not add QSO data to database");
  	
} // **** end of switch

$time = "";
$timeoff = "";
$date = "";

} // ########## end of "if ($submit)"

if ($qsoid) {
###############################################################################################################
# For Field Day logging - fetch
###############################################################################################################
switch ($program) {
	case "FIELDDAY":
  		$sql = "SELECT qsoid, mycall, frequency, mode, date, time, callsign, exchange, arrlsec FROM fdqso WHERE qsoid = '$qsoid'";
  		break;
	default:
  		$sql="SELECT qsoid, mycall, date, time, frequency, mode, power, callsign, rstsent, rstreceived, timeoff, city, state, 
    		    	name, qslsent, qslreceived, comments FROM qso WHERE qsoid='$qsoid'";
}
  $result = mysql_query($sql, $db)
      or error_die("<font size=+1>An error occured<hr>Could not connect to the QSO database. $sql");
  $myrow = mysql_fetch_array($result); 
} // end of "if ($qsoid)"

if ($edited) {
switch ($program) {
	case "FIELDDAY":
		if (strlen($time) == 0)
			$time = date("H:i");
		/* if leading zero is missing (midnight through 10 am), then add leading zero - N4FWD */
  		if (strlen($time) < 4) 
  			$time = substr("0000".$time, -4);
		break;
	default:
  if (strlen($time) == 0)
     {
         if ($utctime != "N") 
             $time = gmdate("H:i:s");
         else
             $time = date("H:i:s");
     }
  if (strlen($time) < 5)
    $time = $time."00";
  if (strlen($timeoff == 0))
     $timeoff = $time;
  if (strlen($timeoff) < 5)
     $timeoff = $timeoff."00";
}

  $callsign = strtoupper($callsign);
  $date = date("Y-m-d",strtotime($date));
  
###############################################################################################################
# For Field Day logging - edit
###############################################################################################################
switch ($program) {
	case "FIELDDAY":
  		$exchange = strtoupper($exchange);
  		$arrlsec = strtoupper($arrlsec);
  		$sql = "UPDATE fdqso SET mycall = '$logcallid', frequency = '$frequency', mode = '$mode', date = '$date', time = '$time',
  		 	callsign = '$callsign', exchange = '$exchange', arrlsec = '$arrlsec' Where qsoid = '$edited'";
		break;
	default:
		$city = ucwords ($city);
		$name = ucwords ($name);
		if ($qslsent == "on") $qslsent = "Y";
		if ($qslreceived == "on") $qslreceived = "Y";  
		$sql="UPDATE qso SET mycall = '$mycall', date = '$date', time = '$time', frequency = '$frequency', 
                       mode = '$mode', power = '$power', callsign = '$callsign', rstsent = '$rsent', 
		       rstreceived = '$rreceived', timeoff = '$timeoff', city = '$city',
                       state = '$spc', name = '$name', comments = '$comments', qslsent = '$qslsent', 
		       qslreceived = '$qslreceived' WHERE qsoid = '$edited'";
}
  $result = mysql_query ($sql, $db)
     or error_die ("Could not update QSO data in database");

} // if ($edited)
if ($nonduplication) {
	header ("Cache-Control: no-cache:");
	header ("Pragma: no-cache");
}
?>
<html>
   <head>
   <title>Log entry for 
<?php
switch ($program) {
	case "FIELDDAY":
		echo $mastercall;
		break;
	default:
 		echo $mycallsign; 
}
?>
</title>
 
<link rel="stylesheet" type="text/css" href="logentry_style.css" />
</head>
<body <?php echo "bgcolor = \"$pagebackground\""; ?>>
<font face="Arial" size="6"><center><b>
<?php
switch ($program) {
        case "FIELDDAY":
                echo $mastercall;
                break;
        default:
                echo $mycallsign;
}
?>'s phpHamLog</b></center></font><br><br>

<?

        echo "<font face=\"Arial\">System Message: <b>" . $note_msg . "</b>&nbsp</td>\n";

        if ( $loggedin) {
            echo "<p class=\"menu\">";
            echo "<a href=\"logentry.php?user=owner\">QSO Entry</a> |";
            echo "<a href=\"view.php?user=owner\">Browse the Log</a> |";
            echo "<a href=\"index.php\">Main menu</a> |";
            echo "<a href=\"logout.php\">Logout</a>";
            echo "</p>";
        } else {
            echo "<p class=\"menu\">";
            echo "<a href=\"view.php?user=owner\">Browse the Log</a> |";
            echo "</p>";
        }
?>

<form action="<?php echo $myphphamlogroot?>/logentry.php" method="post">
<?php 
  if ($qsoid) {
      echo "<input type=\"hidden\" name=\"edited\" value=\"".$qsoid."\">";
    }

# if ( $loggedin ) 
	# echo "  You are logged in as $logcallid.<br><br>\n";
# else
	# echo "  You are not logged in yet!<br><br>\n";
?>
<table>

<?php 

if ($qsoid) {
############################### Build entry table row Existing QSO######################################################

# Note: I commented these out and made the time boxes bigger so that 
# the seconds weren't lost on times that had them.  If the user entered 
# no time and the system filled it in, you'd have nonzero seconds which 
# would be lost by modify_time. --dbotkin--  2001-10-20
#####Modify the time format
#    $time = modify_time($myrow[time]);
#    $timeoff = modify_time($myrow[timeoff]);


############################### Build Field Day/ Contest form #################################################
switch ($program) {
	case "FIELDDAY":
/* build header info */
  		echo "<tr>\n";
    		echo "<td size-\"15\" maxlen=\"15\"><font face=\"Arial\" size=\"-2\"><b>My Call</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>Time</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>Frequency</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>Mode</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>Power</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>Call</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>Exchange</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>ARRL Sec</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>&nbsp;</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>&nbsp;</b></font></td>\n";
  		echo "</tr>\n";
/* populate table data */
		echo "<tr>\n";
    		echo " <td><input type=\"text\" name=\"call\" size=\"15\" maxlen=\"15\" value=\"".$myrow[mycall]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"frequency\" size=\"10\" maxlen=\"10\" value=\"".$myrow[frequency]."\"></td>\n";
    		echo " <td><select name=\"mode\">\n";
    		do {
      			$dbmode = $myrow[mode];
      			$smode = $mymodes[key($mymodes)];
      			echo "<option value=\"".$smode."\"";
      			if (strcmp($smode, $dbmode) == 0)
        			echo " selected ";
      			echo ">".$smode."</option>\n";
    		} while (next($mymodes));
    		echo "</select></td>\n";
    		echo " <td><input type=\"text\" name=\"date\" size=\"10\" maxlen=\"10\" value=\"".$myrow[date]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"time\" size=\"8\" maxlen=\"8\" value=\"".$myrow[time]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"call\" size=\"15\" maxlen=\"15\" value=\"".$myrow[callsign]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"exchange\" size=\"10\" maxlen=\"10\" value=\"".$myrow[exchange]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"arrlsec\" size=\"10\" maxlen=\"10\" value=\"".$myrow[arrlsec]."\"></td>\n";
    		echo "</tr>\n";
    		break;
	default: 
############################### Build Normal logging form #################################################
/* build header info */
  		echo "<tr>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">RST</font></td>\n";
     		echo "<td><font face=\"Arial\">RST</font></td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
  		echo "</tr>\n";
  		echo "<tr>\n";
     		echo "<td><font face=\"Arial\">My Call</td>\n";
     		echo "<td><font face=\"Arial\">Date</td>\n";
     		echo "<td><font face=\"Arial\">Time</td>\n";
     		echo "<td><font face=\"Arial\">Frequency</td>\n";
     		echo "<td><font face=\"Arial\">Mode</td>\n";
     		echo "<td><font face=\"Arial\">Power</td>\n";
     		echo "<td><font face=\"Arial\">Sent</td>\n";
     		echo "<td><font face=\"Arial\">Rcvd</td>\n";
     		echo "<td><font face=\"Arial\">Time Off</td>\n";
  		echo "</tr>\n";
/* populate data */
  		echo "<tr>\n";
    		echo " <td><select name=\"mycall\">\n";
    		do {
      			$callsign = $mycallsigns[key($mycallsigns)];
      			$dbcall = $myrow[mycall];
      			echo "<option value=\"".$callsign."\"";
      			if (strcmp($callsign, $dbcall) == 0)
        			echo " selected ";
      			echo ">".$callsign."</option>\n";
    		} while (next($mycallsigns));
    		echo "</select></td>\n";    
    		echo " <td><input type=\"text\" name=\"date\" size=\"10\" maxlen=\"10\" value=\"".$myrow[date]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"time\" size=\"8\" maxlen=\"8\" value=\"".$myrow[time]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"frequency\" size=\"10\" maxlen=\"10\" value=\"".$myrow[frequency]."\"></td>\n";
    		echo " <td><select name=\"mode\">\n";
    		do {
      			$dbmode = $myrow[mode];
      			$smode = $mymodes[key($mymodes)];
      			echo "<option value=\"".$smode."\"";
      			if (strcmp($smode, $dbmode) == 0)
        			echo " selected ";
      			echo ">".$smode."</option>\n";
    		} while (next($mymodes));
    		echo "</select></td>\n";
    		echo " <td><input type=\"text\" name=\"power\" size=\"10\" maxlen=\"10\" value=\"".$myrow[power]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"rsent\" size=\"3\" maxlen=\"3\" value=\"".$myrow[rstsent]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"rreceived\" size=\"3\" maxlen=\"3\" value=\"".$myrow[rstreceived]."\"></td>\n";
    		echo " <td><input type=\"text\" name=\"timeoff\" size=\"8\" maxlen=\"8\" value=\"".$myrow[timeoff]."\"></td>\n";
    		echo "</tr>\n";
} /* end of build switch */

######################### End of Entry table row #######################################################
 } else {
######################### Build entry table row New QSO###############################################################

############################### Build Field Day/ Contest form #################################################
switch ($program) {
	case "FIELDDAY":
/* Build header table */
		echo "<tr>\n";
    		echo "<td size-\"15\" maxlen=\"15\"><font face=\"Arial\" size=\"-2\"><b>Call</b></font></td>\n";
    		echo "<td><font face=\"Arial\" size=\"-2\"><b>Exchange</b></font></td>\n";
		echo "<td><font face=\"Arial\" size=\"-2\"><b>ARRL Sec</b></font></td>\n";
    		echo "<td><font face=\"Arial\" size=\"-2\"><b>Frequency</b></font></td>\n";
    		echo "<td><font face=\"Arial\" size=\"-2\"><b>Mode</b></font></td>\n";
    		echo "<td><font face=\"Arial\" size=\"-2\"><b>Date</b></font></td>\n";
     		echo "<td><font face=\"Arial\" size=\"-2\"><b>Time</b></font></td>\n";
     		echo "</tr>\n";
/* Populate data */
		echo "<tr>\n";
        	echo " <td><input type=\"text\" name=\"call\" size=\"15\" maxlen=\"15\" value=\"\"></td>\n";
        	echo " <td><input type=\"text\" name=\"exchange\" size=\"10\" maxlen=\"10\" value=\"\"></td>\n";
        	echo " <td><input type=\"text\" name=\"arrlsec\" size=\"10\" maxlen=\"10\" value=\"\"></td>\n";
    		echo " <td><input type=\"text\" name=\"frequency\" size=\"10\" maxlen=\"10\" value=\"$frequency\"></td>\n";
    		echo " <td><select name=\"mode\">\n";
    		do {
      			$dbmode = $mode;
      			$smode = $mymodes[key($mymodes)];
      			echo "<option value=\"".$smode."\"";
      			if (strcmp($smode, $dbmode) == 0)
        			echo " selected ";
      			echo ">".$smode."</option>\n";
    		} while (next($mymodes));
    		echo "</select></td>\n";
    		echo " <td><input type=\"text\" name=\"date\" size=\"10\" maxlen=\"10\" value=\"$date\"></td>\n";
    		echo " <td><input type=\"text\" name=\"time\" size=\"8\" maxlen=\"8\" value=\"\"></td>\n";
    		echo "</tr>\n";
    		break;
	default:
################JIM############ Build Normal logging form #################################################
/* build header info */
  		echo "<tr>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">RST</font></td>\n";
     		echo "<td><font face=\"Arial\">RST</font></td>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
  		echo "</tr>\n";
  		echo "<tr>\n";
     		echo "<td><font face=\"Arial\">&nbsp</td>\n";
     		echo "<td><font face=\"Arial\">Date</td>\n";
     		echo "<td><font face=\"Arial\">Frequency</td>\n";
     		echo "<td><font face=\"Arial\">Mode</td>\n";
     		echo "<td><font face=\"Arial\">Power</td>\n";
     		echo "<td><font face=\"Arial\">Time On</td>\n";
     		echo "<td><font face=\"Arial\">Sent</td>\n";
     		echo "<td><font face=\"Arial\">Rcvd</td>\n";
     		echo "<td><font face=\"Arial\">Time Off</td>\n";
  		echo "</tr>\n";
/* populate data */
		echo "<tr>\n";
    		echo " <td><select name=\"mycall\">\n";
    		do {
      			$callsign = $mycallsigns[key($mycallsigns)];
      			$dbcall = $mycall;
      			echo "<option value=\"".$callsign."\"";
      			if (strcmp($callsign, $dbcall) == 0)
        			echo " selected";
      			echo ">".$callsign."</option>\n";
    		} while (next($mycallsigns));
    		echo "</select></td>\n";    

/*
                $date  = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
                $date  = date("Y-m-d",$date);
*/

                $date  = date("Y-m-d");

                if (strlen($date) == 0)
                {
                    if ($utctime != "N")
                        $date = gmdate("Y-m-d");
                    else
                        $time = date("Y-m-d");
                }

                if (strlen($time) == 0)
                {
                    if ($utctime != "N")
                        $time = gmdate("H:i:s");
                    else
                        $time = date("H:i:s");
                }


    		echo " <td><input type=\"text\" name=\"date\" size=\"10\" maxlen=\"10\" value=\"$date\"></td>\n";
    		echo " <td><input type=\"text\" name=\"frequency\" size=\"15\" maxlen=\"15\" value=\"$frequency\"></td>\n";
    		echo " <td><select name=\"mode\">\n";
    		do {
      			$dbmode = $mode;
      			$smode = $mymodes[key($mymodes)];
      			echo "<option ";
      			if (strcmp($dbmode, $smode) == 0)
        			echo " selected ";
      			echo ">".$smode."</option>\n";
    		} while (next($mymodes));
    		echo "</select></td>\n";
    		echo " <td><input type=\"text\" name=\"power\" size=\"10\" maxlen=\"10\" value=\"$power\"></td>\n";
    		echo " <td><input type=\"text\" name=\"time\" size=\"5\" maxlen=\"5\" value=\"$time\"></td>\n";
    		echo " <td><input type=\"text\" name=\"rsent\" size=\"3\" maxlen=\"3\" value=\"$rsent\"></td>\n";
    		echo " <td><input type=\"text\" name=\"rreceived\" size=\"3\" maxlen=\"3\" value=\"$rreceived\"></td>\n";
    		echo " <td><input type=\"text\" name=\"timeoff\" size=\"5\" maxlen=\"5\" value=\"$timeoff\"></td>\n";
} /* end of build switch */
    echo "</tr>\n";
######################### End of Entry table row #######################################################
} /* end of "if ($qsoid)" */
?>
</table>

<?php 
###########################################################################################################################################
# Only show this next section if in NORMAL mode
###########################################################################################################################################

if (strcmp($program,"NORMAL") == 0) {
?>
<table>
  <tr>
     <td><font face="Arial">&nbsp</td>
     <td><font face="Arial">&nbsp</td>
     <td><font face="Arial">&nbsp</td>
     <td><font face="Arial">&nbsp</td>
     <td><font face="Arial">QSL</td>
     <td><font face="Arial">QSL</td>
     <td colspan=4><font face="Arial">&nbsp</td>
  </tr>
  <tr>
     <td><font face="Arial">QSO Call</td>
     <td><font face="Arial">Name</td>
     <td><font face="Arial">City</td>
     <td><font face="Arial">State/Province/Code</td>
     <td><font face="Arial">Sent</td>
     <td><font face="Arial">Rcvd</td>
     <td colspan=4><font face="Arial">&nbsp</td>
  </tr>

<?php if ($qsoid) {
echo <<<EOR
<!-- #look######################Next row of entries Existing QSO############################################ --!>
  <tr>
     <td><input type="text" name="callsign" size="15" maxlen="15" value="{$myrow[callsign]}"</td>
     <td><input type="text" name="name" size="15" maxlen="50" value="{$myrow[name]}"></td>
     <td><input type="text" name="city" size="15" maxlen="50" value="{$myrow[city]}"></td>
     <td><input type="text" name="spc" size="15"  maxlen="15" value="{$myrow[state]}"></td>

<!-- ################ check qsl* boxes if needed ############################# --!>
EOR;
     		if ($myrow[qslsent] == "Y") {
         		echo "<td><input type=\"checkbox\" name=\"qslsent\" checked></td>\n";
       		} else {
         		echo "<td><input type=\"checkbox\" name=\"qslsent\"></td>\n";
       		}

     		if ($myrow[qslreceived] == "Y") {   
         		echo "<td><input type=\"checkbox\" name=\"qslreceived\" checked></td>\n";
       		} else {
         		echo "<td><input type=\"checkbox\" name=\"qslreceived\"></td>\n";
       		}
echo <<<EOR
     <!--td colspan=4>&nbsp;</td--!>
  </tr>
  <tr>
     <td colspan=12><font face="Arial">Comments</td>
  </tr>
  <tr>
    <td colspan=12><textarea name="comments" rows=10 cols=45 wrap="virtual">{$myrow[comments]}</textarea></td>
  </tr>
EOR;
	} else {
echo <<<EOR
<!-- ########################Next row of entries New QSO############################################ --!>
  <tr>
     <td><input type="text" name="callsign" size="15" maxlen="15" value=""</td>
     <td><input type="text" name="name" size="15" maxlen="50" value=""></td>
     <td><input type="text" name="city" size="15" maxlen="50" value=""></td>
     <td><input type="text" name="spc" size="15"  maxlen="15" value=""></td>
     <td><input type="checkbox" name="qslsent"></td>
     <td><input type="checkbox" name="qslreceived"></td>
     <td colspan=4>&nbsp</td>
  </tr>
  <tr>
     <td colspan=12>Comments</td>
  </tr>
  <tr>
     <td colspan=12><textarea name="comments" rows=10 cols=45 wrap="virtual"></textarea></td>
  </tr>
EOR;
	} /* end of "if ($qsoid)" */
########################## End of NORMAL mode table #####################################################################################
} /* end of "NORMAL" */
?>

</table>
<?php
###############################################################################################################################
# Button Values
###############################################################################################################################
 
if ($qsoid) {
################################### Value for "Submit" Existing QSO ###################################
	echo "<input type=\"submit\" name=\"edit\" value=\"Edit\">";
} else {
################################### Value for "Submit" New QSO ######################################
	echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
}
?>

<input type="submit" name="cancel" value="Cancel">
<input type="submit" name="logout" value="Logout">
<input type="submit" name="ton" value="Start QSO">
<input type="submit" name="toff" value="Finish QSO">
</form>

<table border="0" cellpadding = "3" cellspacing = "0">

<?php

####################################################### Header for QSO list ####################################
#####################################################################################
#  Field Day Logging
#####################################################################################
switch ($program) {
	case "FIELDDAY":
?>
  <tr>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>ARRL</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
  </tr>
  <tr>
    <td size-"15" maxlen="15"><font face="Arial" size="-2"><b>Call</b></font></td>
     <td><font face="Arial" size="-2"><b>Frequency</b></font></td>
     <td><font face="Arial" size="-2"><b>Mode</b></font></td>
     <td><font face="Arial" size="-2"><b>Date</b></font></td>
     <td><font face="Arial" size="-2"><b>Time</b></font></td>
     <td><font face="Arial" size="-2"><b>Exchange</b></font></td>
     <td><font face="Arial" size="-2"><b>Section</b></font></td>
     <td><font face="Arial" size="-2"><b>Worked by</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
  </tr>
<?php
		break;
	default:
#########################################################
#  NORMAL Logging
#########################################################
?>
  <tr>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>RST</b></font></td>
     <td><font face="Arial" size="-2"><b>RST</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>QSL</b></font></td>
     <td><font face="Arial" size="-2"><b>QSL</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
  </tr>
  <tr>
     <td><font face="Arial" size="-2"><b>Date</b></font></td>
     <td><font face="Arial" size="-2"><b>Time</b></font></td>
     <td><font face="Arial" size="-2"><b>Frequency</b></font></td>
     <td><font face="Arial" size="-2"><b>Mode</b></font></td>
     <td><font face="Arial" size="-2"><b>Power</b></font></td>
     <td><font face="Arial" size="-2"><b>Call</b></font></td>
     <td><font face="Arial" size="-2"><b>Sent</b></font></td>
     <td><font face="Arial" size="-2"><b>Rcvd</b></font></td>
     <td><font face="Arial" size="-2"><b>Time Off</b></font></td>
     <td><font face="Arial" size="-2"><b>City</b></font></td>
     <td><font face="Arial" size="-2"><b>S/P/C</b></font></td>
     <td><font face="Arial" size="-2"><b>Name</b></font></td>
     <td><font face="Arial" size="-2"><b>Sent</b></font></td>
     <td><font face="Arial" size="-2"><b>Rcvd</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
     <td><font face="Arial" size="-2"><b>&nbsp;</b></font></td>
  </tr>
<?php 
} /* end of switch */
?>

<?php
###############################################################################################################
# QSO list -- For Field Day logging, we will pull up the last 20 entries of a calling unit (dup check)
###############################################################################################################
switch ($program) {
	case "FIELDDAY":
		$sql="SELECT qsoid, mycall,frequency, mode, date, time, callsign, exchange, arrlsec FROM fdqso ORDER BY date DESC, time DESC  LIMIT 20";
		$result = mysql_query($sql, $db)
			or  error_die("<font size=+1>An error occured<hr>Could not connect to the QSO database. $sql");
		$myrow = mysql_fetch_array($result);
		$rowcolor = $tbldark;
		$count = 0;
		do {
			$count++;
			echo "<tr bgcolor = \"$rowcolor\">
            			<td><font face=\"Arial\" size=\"-2\">" .$myrow[callsign]. "</td>\n";
            		echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[frequency]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[mode]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[date]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[time]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[exchange]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[arrlsec]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[mycall]. "</td>\n";
     			echo "</tr>";
     			if ($rowcolor == $tbldark) {
        			$rowcolor = $tbllight;
     			} else {
        			$rowcolor = $tbldark;
     			}
  		} while ($myrow=mysql_fetch_array($result));
  		break;
	default:
###############################################################################
# NORMAL Logging 
###############################################################################
  # here we are going to grab the last 10 entries in the database (no, it is not last 10 based off date/time, it is
  # based on entry order!) and put them up in case they need to be edited.
  
		$sql="SELECT qsoid, date, time, frequency, mode, power, callsign, rstsent, rstreceived, timeoff, city, state, 
  		      name, qslsent, qslreceived FROM qso ORDER BY qsoid DESC LIMIT 10";

		$result = mysql_query($sql, $db)
      			or error_die("<font size=+1>An error occured<hr>Could not connect to the QSO database. $sql");

  		$myrow = mysql_fetch_array($result);
  		$rowcolor = $tbldark; 
  		$count = 0;
  		do { 
     			$count++;
     			echo "<tr bgcolor = \"$rowcolor\">
        		    	<td><font face=\"Arial\" size=\"-2\">" .$myrow[date]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[time]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[frequency]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[mode]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[power]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[callsign]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[rstsent]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[rstreceived]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[timeoff]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[city]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[state]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[name]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[qslsent]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\">" .$myrow[qslreceived]. "</td>\n";
     			echo "     <td><font face=\"Arial\" size=\"-2\"><a href=\"logentry.php?qsoid=".$myrow[qsoid]."\">Edit</a></td>\n";
     			k3xs_qrzcom_interface($myrow[callsign]);
     			echo "</tr>";
     			if ($rowcolor == $tbldark) {
        			$rowcolor = $tbllight;
     			} else {
        			$rowcolor = $tbldark;
     			}
  		} while ($myrow=mysql_fetch_array($result));
} /* end of switch */

?>
</table>
<br><font face="Arial" size="-2"><a href="index.php">Home</a></font>
</form>
</body>
</html>
Return current item: phpHamLog