?>
" SIZE=19 disabled /></TD></TR>	<!-- 9/13/08 -->
<?php 
                break;
            case "1":
                ?>
			&nbsp;OSGB:<INPUT TYPE="text" NAME="frm_ngs" VALUE="<?php 
                print LLtoOSGB($row['lat'], $row['lng']);
                ?>
" SIZE=19 disabled /></TD></TR>	<!-- 9/13/08 -->
<?php 
                break;
            case "2":
                ?>
			&nbsp;UTM:<INPUT TYPE="text" NAME="frm_ngs" VALUE="<?php 
                print LLtoUTM($row['lat'], $row['lng']);
                ?>
" SIZE=19 disabled /></TD></TR>	<!-- 9/13/08 -->
<?php 
                break;
            default:
                print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />";
        }
    }
    // end if (my_is_float($lat))
    if (isset($rowtr)) {
        // got tracks?
        print "<TR CLASS='odd'><TD COLSPAN=2 ALIGN='center'><B>TRACKING</B></TD></TR>";
        print "<TR CLASS='even'><TD>Course: </TD><TD>" . $rowtr['course'] . ", Speed:  " . $rowtr['speed'] . ", Alt: " . $rowtr['altitude'] . "</TD></TR>";
        print "<TR CLASS='odd'><TD>Closest city: </TD><TD>" . $rowtr['closest_city'] . "</TD></TR>";
        print "<TR CLASS='even'><TD>Status: </TD><TD>" . $rowtr['status'] . "</TD></TR>";
function mail_it($to_str, $text, $ticket_id, $text_sel = 1, $txt_only = FALSE)
{
    // 10/6/08, 10/15/08,  2/18/09, 3/7/09
    global $istest;
    /*
    Subject		A
    Inciden		B  Title
    Priorit		C  Priorit
    Nature		D  Nature
    Written		E  Written
    Updated		F  As of
    Reporte		G  By
    Phone: 		H  Phone: 
    Status:		I  Status:
    Address		J  Location
    Descrip		K  Descrip
    Disposi		L  Disposi
    Start/end	M
    Map: " 		N  Map: " 
    Actions		O
    Patients	P
    Host		Q
    911 contact	R				// 6/26/10
    */
    switch ($text_sel) {
        // 7/7/09
        case 1:
            $match_str = strtoupper(get_variable("msg_text_1"));
            // note case
            break;
        case 2:
            $match_str = strtoupper(get_variable("msg_text_2"));
            break;
        case 3:
            $match_str = strtoupper(get_variable("msg_text_3"));
            break;
    }
    if (empty($match_str)) {
        $match_str = " " . implode("", range("A", "R"));
    }
    // empty get all - force non-zero hit
    //	require_once("cell_addrs.inc.php");			// 10/22/08
    //	snap (__LINE__, count($cell_addrs));
    //	$cell_addrs = array( "vtext.com", "messaging.sprintpcs.com", "txt.att.net", "vmobl.com", "myboostmobile.com");		// 10/5/08
    //	if ($istest) {array_push($cell_addrs, "gmail.com");};
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}ticket` WHERE `id`='{$ticket_id}' LIMIT 1";
    $ticket_result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    $t_row = stripslashes_deep(mysql_fetch_array($ticket_result));
    //	dump($t_row);
    $eol = "\n";
    $locale = get_variable('locale');
    $message = "";
    $_end = good_date_time($t_row['problemend']) ? "  End:" . $t_row['problemend'] : "";
    //
    for ($i = 0; $i < strlen($match_str); $i++) {
        if (!($match_str[$i] == " ")) {
            switch ($match_str[$i]) {
                case "A":
                    break;
                case "B":
                    $message .= "Incident: " . $t_row['scope'] . $eol;
                    break;
                case "C":
                    $message .= "Priority: " . get_severity($t_row['severity']) . $eol;
                    break;
                case "D":
                    $message .= "Nature: " . get_type($t_row['in_types_id']) . $eol;
                    break;
                case "J":
                    $str = "";
                    $str .= empty($t_row['street']) ? "" : $t_row['street'] . " ";
                    $str .= empty($t_row['city']) ? "" : $t_row['city'] . " ";
                    $str .= empty($t_row['state']) ? "" : $t_row['state'];
                    $message .= empty($str) ? "" : "Addr: " . $str . $eol;
                    break;
                case "K":
                    $message .= empty($t_row['description']) ? "" : "Descr: " . wordwrap($t_row['description']) . $eol;
                    break;
                case "G":
                    $message .= "Reported by: " . $t_row['contact'] . $eol;
                    break;
                case "H":
                    $message .= empty($t_row['phone']) ? "" : "Phone: " . format_phone($t_row['phone']) . $eol;
                    break;
                case "E":
                    $message .= empty($t_row['date']) ? "" : "Written: " . format_date_time($t_row['date']) . $eol;
                    break;
                case "F":
                    $message .= "Updated: " . format_date_time($t_row['updated']) . $eol;
                    break;
                case "I":
                    $message .= "Status: " . get_status($t_row['status']) . $eol;
                    break;
                case "L":
                    $message .= empty($t_row['comments']) ? "" : "Disp: " . wordwrap($t_row['comments']) . $eol;
                    break;
                case "M":
                    $message .= get_text("Run Start") . ": " . format_date_time($t_row['problemstart']) . $_end . $eol;
                    break;
                case "N":
                    if ($locale == 0) {
                        $usng = LLtoUSNG($t_row['lat'], $t_row['lng']);
                        $message .= "Map: " . $t_row['lat'] . " " . $t_row['lng'] . ", " . $usng . "\n";
                    }
                    if ($locale == 1) {
                        $osgb = LLtoOSGB($t_row['lat'], $t_row['lng']);
                        $message .= "Map: " . $t_row['lat'] . " " . $t_row['lng'] . ", " . $osgb . "\n";
                    }
                    if ($locale == 2) {
                        $utm = LLtoUTM($t_row['lat'], $t_row['lng']);
                        $message .= "Map: " . $t_row['lat'] . " " . $t_row['lng'] . ", " . $utm . "\n";
                    }
                    break;
                case "P":
                    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}patient` WHERE ticket_id='{$ticket_id}'";
                    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
                    if (mysql_affected_rows() > 0) {
                        $message .= "\nPatient:\n";
                        while ($pat_row = stripslashes_deep(mysql_fetch_array($result))) {
                            $message .= $pat_row['name'] . ", " . $pat_row['updated'] . "- " . wordwrap($pat_row['description'], 70) . "\n";
                        }
                    }
                    unset($result);
                    break;
                case "O":
                    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}action` WHERE `ticket_id`='{$ticket_id}'";
                    // 10/16/08
                    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
                    // 3/22/09
                    if (mysql_affected_rows() > 0) {
                        $message .= "\nActions:\n";
                        $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
                        while ($act_row = stripslashes_deep(mysql_fetch_array($result))) {
                            $message .= $act_row['updated'] . " - " . wordwrap($act_row['description'], 70) . "\n";
                        }
                    }
                    unset($result);
                    break;
                case "Q":
                    $message .= "Tickets host: " . get_variable('host') . $eol;
                    break;
                case "R":
                    // 6/26/10
                    $message .= empty($t_row['nine_one_one']) ? "" : get_text('911 Contacted') . ": " . wordwrap($t_row['nine_one_one']) . $eol;
                    //	11/10/11
                    break;
                default:
                    $message = "Match string error:" . $match_str[$i] . " " . $match_str . $eol;
            }
            // end switch ()
        }
        // end if(!($match_...))
    }
    // end for ($i...)
    $message = str_replace("\n.", "\n..", $message);
    // see manual re mail win platform peculiarities
    $subject = strpos($match_str, "A") ? $text . $t_row['scope'] . " (#" . $t_row['id'] . ")" : "";
    if ($txt_only) {
        return $subject . "\n" . $message;
        // 2/16/09
    } else {
        do_send($to_str, $subject, $message);
    }
}
function LLtoUSNG($lat, $lon, $precision = 5)
{
    // note default precision
    if (empty($lat) || empty($lon)) {
        return "";
    }
    global $NORTHING_OFFSET, $UTMNorthing, $zoneNumber, $UTMEasting, $UTMZone;
    global $BLOCK_SIZE;
    $lat = (double) $lat;
    $lon = (double) $lon;
    // convert $lat/$lon to UTM coordinates
    $coords = array(2);
    $coords = LLtoUTM($lat, $lon, $coords);
    // ...then convert UTM to $USNG
    if ($lat < 0) {
        // Use offset for southern hemisphere
        $UTMNorthing += $NORTHING_OFFSET;
    }
    $USNGLetters = findGridLetters($zoneNumber, $UTMNorthing, $UTMEasting);
    $USNGNorthing = round($UTMNorthing) % $BLOCK_SIZE;
    $USNGEasting = round($UTMEasting) % $BLOCK_SIZE;
    // added... truncate digits to achieve specified $precision
    $USNGNorthing = floor($USNGNorthing / pow(10, 5 - $precision));
    $USNGEasting = floor($USNGEasting / pow(10, 5 - $precision));
    $USNG = $UTMZone . $USNGLetters . " ";
    // REVISIT: Modify to incorporate dynamic $precision ?
    for ($i = strlen($USNGEasting); $i < $precision; $i++) {
        $USNG .= "0";
    }
    $USNG .= $USNGEasting . " ";
    for ($i = strlen($USNGNorthing); $i < $precision; $i++) {
        $USNG .= "0";
    }
    $USNG .= $USNGNorthing;
    return $USNG;
}