<?php
/*=======================================================================
 *
 * tracking.php
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/


include_once ("../include/mcglobal.inc.php");

// Check HTTP-Parameters
getSecHttpVars("1",array("f_act", "trackingID", "selectedLanguage"));


$trackingID = trim($trackingID);

// Write logdata into log file
if ($trackingID != "") :
   $currentTime = getDateTime("0");
   writeToFile("../log/tracking.log", $currentTime . " : " . $trackingID);
endif;

if ($selectedLanguage == "" || !is_numeric($selectedLanguage)) : $selectedLanguage = $languageSelected; endif;
$languageSelected = $selectedLanguage;

getLanguage(__FILE__);
getCurrentScript(__FILE__);


$pageTitel = getLngt("Sendungsverfolgung");

// ---------------------------------------------------------------------------

// Event messages
$eventMsgArray["EVENT_101"] = getLngt("Sendung hat Versandzentrum verlassen.");   // Electronic Manifest transmitted to the carrier and the carrier’s truck has departed seller facility
$eventMsgArray["EVENT_102"] = getLngt("Sendung wurde vom Transporteur übernommen.");   // Origin scan which confirms possession by the carrier

//$eventMsgArray["EVENT_201"] = getLngt("Ankunft der Sendung im zentralen Hub.");   // Arrived at any of the carrier facilities
$eventMsgArray["EVENT_201"] = getLngt("Ankunft der Sendung im Verteilzentrum.");   // Arrived at any of the carrier facilities
$eventMsgArray["EVENT_202"] = getLngt("Ausgang der Sendung aus dem zentralen Hub.");   // Departed any of the carrier facilities

// $eventMsgArray["EVENT_203"] = "Arrived at destination country";   // Arrived at the destination country
// $eventMsgArray["EVENT_204"] = "Initiated customs clearance process";   // Customs has started to clear the package
// $eventMsgArray["EVENT_205"] = "Completed customs clearance process";   // Customs has cleared the package
// $eventMsgArray["EVENT_206"] = "In transit to pickup location";   // Package is in transit to pickup location
// $eventMsgArray["EVENT_207"] = "Problem resolved and shipment is in transit";   // Resolution of exception scan and package is in transit again
// $eventMsgArray["EVENT_208"] = "Your selected store is closed for delivery and your shipment has been rerouted to a nearby store. The carrier will provide more information about the new store";   // Customer pick-up location is closed and the package was rerouted to a nearby pick-up location

$eventMsgArray["EVENT_300"] = getLngt("NOT DISPLAYED");   // Tendered to alternate carrier, line haul complete
$eventMsgArray["EVENT_301"] = getLngt("Sendung zugestellt.");   // Delivered to the customer directly
$eventMsgArray["EVENT_302"] = getLngt("Zustellung läuft.");   // On the last leg of delivery to the customer
$eventMsgArray["EVENT_304"] = getLngt("Vergeblicher Zustellversuch.");   // Carrier attempted delivery, but unable to deliver to customer
$eventMsgArray["EVENT_306"] = getLngt("Kontaktaufnahme");   // Carrier has contacted the customer to arrange delivery of the package
$eventMsgArray["EVENT_307"] = getLngt("Neuer Auslieferungstermin vereinbart");   // Carrier has scheduled delivery of the package with the customer
//$eventMsgArray["EVENT_308"] = getLngt("Sendung ist verfügbar für Abholung");   // Package is available for pickup from pickup location
$eventMsgArray["EVENT_308"] = getLngt("Sendung steht zur Abholung bereit.");   // Package is available for pickup from pickup location
$eventMsgArray["EVENT_309"] = getLngt("Rücksendung der Ware");   // Package was delivered back to seller’s facility
// $eventMsgArray["EVENT_310"] = "Tendered to local postal carrier for final delivery";   // Local postal carrier will perform final delivery to the customer. If assigned a new tracking id, carrier name and tracking id should be provided.
// $eventMsgArray["EVENT_311"] = "Tendered to local postal carrier for final delivery and no proof of delivery will be provided";   // Local postal carrier will perform final delivery to the customer but they will not scan the package as delivered (international use).
$eventMsgArray["EVENT_320"] = getLngt("Kunde hat abgeholt.");
$eventMsgArray["EVENT_328"] = getLngt("Zustellung auf den nächsten Werktag verschoben."); // "Shipment addressed to a company that is closed on weekends. Shipment will be deliverd on the next working day"; // Business closed. The goods/consignements/equipment could not be delivered/collected as the business was closed

$eventMsgArray["EVENT_401"] = getLngt("Falsche Adresse");   // Destination address does not exist or is incorrect
// $eventMsgArray["EVENT_402"] = "Customs clearance delay";   // Any situation which causes a delay clearing customs
$eventMsgArray["EVENT_403"] = getLngt("Empfänger verzogen");   // Consignee no longer lives at the delivery address and left no forwarding address
$eventMsgArray["EVENT_404"] = getLngt("Verzögerung der Auslieferung");   // This represents a definite delay in delivery and will trigger correspondences to the customer to notify them of the delay
$eventMsgArray["EVENT_405"] = getLngt("Ware beschädigt");   // Carrier damaged the package
$eventMsgArray["EVENT_406"] = getLngt("Sendung wird zurückgehalten");   // The package is being held by the carrier
$eventMsgArray["EVENT_407"] = getLngt("Sendung nicht angenommen");   // Consignee refused to accept package
$eventMsgArray["EVENT_408"] = getLngt("Verkäufer hat die Sendung zurückgerufen");   // Seller has requested the package to be returned to sellers facility
// $eventMsgArray["EVENT_409"] = "Lost by carrier";   // Carrier lost the package
$eventMsgArray["EVENT_411"] = "Auf der Packliste avisierte Sendung wurde vom Versender nicht mitgeliefert.";   // Carrier received electronic or paper manifest, but the shipment has not been picked up
$eventMsgArray["EVENT_412"] = "Sendung steht nicht auf der Packliste/Übergabe an falschen Transportservice.";   // Carrier received the package, but not the electronic/paper manifest. This is sent only when the shipment cannot move until the problem is resolved
// $eventMsgArray["EVENT_413"] = "Customer refused shipment due to customs charges";   // Customer has refused shipment due to customs duties, taxes and fees charges.
// $eventMsgArray["EVENT_414"] = "Possible delay in delivery due to arrival at incorrect carrier facility";   // Package was mis-sorted and delivery maybe delayed
// $eventMsgArray["EVENT_415"] = "Received from prior carrier";   // Carrier has received the package from the previous carrier
$eventMsgArray["EVENT_416"] = getLngt("Nicht auslieferbar");   // Package could not be delivered, and seller has instructed the carrier to destroy the package or follow alternate instructions
// $eventMsgArray["EVENT_418"] = "Returning to seller due to incorrect address";   // Unable to complete delivery due to incorrect address and the shipment is being returned to the seller
// $eventMsgArray["EVENT_419"] = "Returning to seller because customer refused delivery";   // Customer refused delivery and the shipment is being returned to the seller 
// $eventMsgArray["EVENT_420"] = "Delay in delivery due to weather or natural disaster";   // Shipment delivery is delayed because of weather or natural disaster
// $eventMsgArray["EVENT_421"] = "Unable to forward shipment to different address";   // Forwarding attempt failed
// $eventMsgArray["EVENT_422"] = "Shipment forwarded to a different delivery address";   // Carrier has forwarded the package to an address
// $eventMsgArray["EVENT_423"] = "Shipment damaged and will not be delivered";  // Carrier has identified the package as damaged, will not complete the delivery, and will dispose of the package
// $eventMsgArray["EVENT_424"] = "Held for payment";  // Delivery of the package cannot be completed until payment is received by Carrier
// $eventMsgArray["EVENT_425"] = "Possible delay in delivery due to extra carrier processing";  // There is possible delay in delivery because the carrier had to perform extra processing outside of the norm
// $eventMsgArray["EVENT_426"] = "Confiscated or seized by an official government authority";  // The package will not be delivered nor returned due to being seized by an official government authority 
// $eventMsgArray["EVENT_427"] = "Held by carrier – seller input required";  // The package is being held by the carrier because they require additional information from seller 
// $eventMsgArray["EVENT_428"] = "Address issue corrected by carrier but delivery could be delayed.";  // The carrier was able to correct the customer’s address without any input from customer or seller
$eventMsgArray["EVENT_451"] = getLngt("Nach Ablauf der Lagerfrist zurückgeschickt.");

$eventMsgArray["EVENT_901"] = getLngt("Sendungsbarcode gelesen");   // Internal Assecutor event

// ---------------------------------------------------------------------------

// Error messages
$errMsgArray["ERROR_101"] = "INVALID TRACKING NUMBER";         // Request contains an invalid tracking number
$errMsgArray["ERROR_102"] = "NO TRACKING INFO FOUND";          // No data exists in the carrier’s system for the given tracking number

$errMsgArray["ERROR_201"] = "INVALID USERID/PASSWORD";         // Request contains an invalid user ID or password
$errMsgArray["ERROR_202"] = "INVALID API VERSION";             // Request contains an incompatible API version
$errMsgArray["ERROR_203"] = "XML DOCUMENT NOT WELL FORMED";    // Request is not a well-formed XML document
$errMsgArray["ERROR_204"] = "XML DOCUMENT NOT VALID";          // Request is not a valid XML document

$errMsgArray["ERROR_301"] = "TRACKING SERVICE NOT AVAILABLE";  // Generic error code to handle any situation

// ---------------------------------------------------------------------------

// Delivery location codes
$deliveryLocCodes["AS_INSTRUCTED"] = getLngt("Anweisungsgemäß");  // Package was delivered as per instructions
$deliveryLocCodes["CARPORT"] = getLngt("Carport");  // Package was left inside a carport
$deliveryLocCodes["CUSTOMER_PICKUP"] = getLngt("Picked up by customer");  // Package was picked up by customer
$deliveryLocCodes["DECK"] = getLngt("Deck");  // Package was left on an outside deck
$deliveryLocCodes["DOCK"] = getLngt("Shipping dock");  // Package was left on dock
$deliveryLocCodes["FRONT_DESK"] = getLngt("Front desk");  // Package was left at front desk
$deliveryLocCodes["FRONT_DOOR"] = getLngt("Front door");  // Package was left in or near the front door
$deliveryLocCodes["GARAGE"] = getLngt("Garage");  // Package was left in or near the garage door
$deliveryLocCodes["GUARD"] = getLngt("Guard");  // Package was handed to a security guard
$deliveryLocCodes["MAILBOX"] = getLngt("Mailbox");  // Package was left inside the residence’s mailbox
$deliveryLocCodes["MAIL_ROOM"] = getLngt("Mail room");  // Package was left in mail room
$deliveryLocCodes["MAIL_SLOT"] = getLngt("Mail slot");  // Package was left in mail slot
$deliveryLocCodes["MC_BOY"] = getLngt("Delivered to male child");  // Package was handed directly to a male child.
$deliveryLocCodes["MC_GIRL"] = getLngt("Delivered to female child");  // Package was handed directly to a female child.
$deliveryLocCodes["MC_MAN"] = getLngt("Delivered to male adult");  // Package was handed directly to a man
$deliveryLocCodes["MC_WOMAN"] = getLngt("Delivered to female adult");  // Package was handed directly to a woman
$deliveryLocCodes["NEIGHBOR"] = getLngt("Left with neighbor");  // Package was handed directly to a neighbor
$deliveryLocCodes["OUTBUILDING"] = getLngt("Outbuilding");  // Package was left in an outbuilding
$deliveryLocCodes["PATIO"] = getLngt("Patio");  // Package was left on an outside patio
$deliveryLocCodes["PORCH"] = getLngt("Porch");  // Package was left on an outside porch
$deliveryLocCodes["REAR_DOOR"] = getLngt("Rear door");  // Package was in or near the rear door
$deliveryLocCodes["RECEIVER"] = getLngt("Resident");  // Package was handed to resident
$deliveryLocCodes["RECEPTIONIST"] = getLngt("Receptionist");  // Package was handed to a receptionist
$deliveryLocCodes["SECURE_LOCATION"] = getLngt("Secure location");  // Package was left in a secure location
$deliveryLocCodes["SIDE_DOOR"] = getLngt("Side door");  // Package was left at side door

// Pickup location codes
$pickupLocCodes["CARRIER_FACILITY"] = getLngt("Available for pickup at carrier facility");  // Package can be picked up from carrier’s hub
$pickupLocCodes["CONVENIENCE_STORE"] = getLngt("Available for pickup at local convenience store");  // Package can be picked up at a local store
$pickupLocCodes["LOCAL_POST_OFFICE"] = getLngt("Available for pickup at your local post office");  // Package can be picked up at local post office

// ------------------------------------------------------------

$trOut = "";
$csEndOut = "";
$cmpOut = "";
$cmp2Out = "";
$tratpOut = "";

$out = getLngt("Ihre Sendung konnte unter der angegebenen Nummer nicht aufgefunden werden.") . "<br>" . getLngt("Bitte kontrollieren Sie noch einmal die Eingabe.");
if ($trackingID == "") :
   $out = getLngt("Bitte geben Sie Ihre Sendungsnummer ein.");
endif;

if ($trackingID != "") :

   // Get the array for formatting the database-values for the output according to the defined type
   $outputFormatField = defineOutputFormats();

   // Check existence of the hash value
   if (existsEntry("meta_object.metaobject",array("mo_hash",$trackingID))) :

      $moId      = getFieldValueFromId("meta_object.metaobject", "mo_hash", $trackingID, "mo_id");
      $moIdRefDB = getFieldValueFromId("meta_object.metaobject", "mo_id", $moId, "mo_id_ref_db");
      $objType   = getFieldValueFromId("meta_object.metaobject", "mo_id", $moId, "mo_obj_type");
      $objId     = getFieldValueFromId("meta_object.metaobject", "mo_id", $moId, "mo_obj_id");
      $moValue   = getFieldValueFromId("meta_object.metaobject", "mo_id", $moId, "mo_value");

      if ($moId != "" && $moId > "0") :

         // Get database instance
         $dbInst = getFieldValueFromId("meta_object.metaobject", "mo_id", $moIdRefDB, "mo_value");

         if ($dbInst != "") :

            // Get database connection
            $db_conn = getDbConnectionSpecial($dbInst, $dbname, $dblogin, $dbpassword);

            if (substr($objType, 0, 5) == "track") :    // Could be "track", "track_job", ...

                  // Charset
                  $result = $db_conn->query("SET NAMES LATIN1");
                  if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());

                  
                  // *** PACKAGE TRACKING ***
                  
                  if ($objType == "track") :

                     // Get tracking data
                     $sqlquery = "SELECT trat.trat_id, trat.jb_id, trat.tr_sort, trat.trat_state, trat.trat_remark,"
                               . "       tratp.tratp_type, tratp.tratp_state, tratp.tratp_remark, tratp.tratp_createtime,"
                               . "       tr.tr_signname, tr.tr_hsno,"
                               . "       ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country"
                               . "  FROM phoenix.tourarticle AS trat, phoenix.tourarticleprocess AS tratp, phoenix.tour AS tr, phoenix.address AS ad"
                               . "  WHERE trat.trat_serialno = '" . $moValue . "' AND"
                               . "        trat.trat_id = tratp.trat_id AND"
                               . "        trat.jb_id = tr.jb_id AND"
                               . "        trat.tr_sort = tr.tr_sort AND"
                               . "        tr.ad_id = ad.ad_id"
                               . "  ORDER BY tratp.tratp_createtime";
   
                     $result = $db_conn->query($sqlquery);
                     if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
      
                     while ($row = $result->fetch_assoc()):
   
                           $tratpOut .= "<tr>\n";
                           $tratpOut .= "  <td width=\"50%\" align=\"left\">\n";
                           $tratpOut .= "    <span class=\"f10np1\">" . $eventMsgArray["EVENT_" . $row["tratp_type"]] . "</span>\n";
                           $tratpOut .= "  </td>\n";
                           $tratpOut .= "  <td width=\"20%\" align=\"left\">\n";
                           if ($row["tratp_state"] >= "1") :
                              $tratpOut .= "    <span class=\"f10np1_green\">" . getLngt("erledigt") . "</span>\n";
                           else :
                              $tratpOut .= "    <span class=\"f10np1_red\">" . getLngt("offen") . "</span>\n";
                           endif;
                           $tratpOut .= "  </td>\n";
                           $tratpOut .= "  <td width=\"30%\" align=\"left\">\n";
                           $tratpOut .= "    <span class=\"f10np1\">" . formatOutput($row["tratp_createtime"],$outputFormatField["tratp_createtime"]) . "</span>\n";
                           $tratpOut .= "  </td>\n";
                           $tratpOut .= "</tr>\n";
                           $tratpOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
                     endwhile;
                     $result->free();
                     
                     // -------------------------------------
   
                     // Get delivery address and data of the end customer
                     $sqlquery = "SELECT trat.jb_id, trat.tr_sort,"
                               . "       tr.tr_signname, tr.tr_hsno, tr.tr_person,"
                               . "       ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country"
                               . "  FROM phoenix.tourarticle AS trat, phoenix.tour AS tr, phoenix.address AS ad"
                               . "  WHERE trat.trat_serialno = '" . $moValue . "' AND"
                               . "        trat.jb_id = tr.jb_id AND"
                               . "        trat.tr_sort = tr.tr_sort AND"
                               . "        tr.ad_id = ad.ad_id"
                               . "  ORDER BY trat.jb_id, trat.tr_sort";
   
                     $result = $db_conn->query($sqlquery);
                     if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
   
                     // The last row is the youngest order with the corresponding station no.
                     while ($row = $result->fetch_assoc()):
   
                           $jbIdOfDelivery = $row["jb_id"];
                           $trSortOfDelivery = $row["tr_sort"];
                           $adStreetOfDelivery = $row["ad_street"];
                           $trHsnoOfDelivery = $row["tr_hsno"];
                           $adZipcodeOfDelivery = $row["ad_zipcode"];
                           $adCityOfDelivery = $row["ad_city"];
                           $adCountryOfDelivery = $row["ad_country"];
                           $trPersonOfDelivery = $row["tr_person"];
                     endwhile;
                     $result->free();
   
                     if ($jbIdOfDelivery != "") :
                        if ($trPersonOfDelivery != "") :
                           $csEndOut .= $trPersonOfDelivery . "<br>\n";
                        endif;
                        $csEndOut .= $adStreetOfDelivery . "&nbsp;" . $trHsnoOfDelivery . "<br>\n";
                        $csEndOut .= $adZipcodeOfDelivery . "&nbsp;" . $adCityOfDelivery . "\n";
                     endif;
                  endif;


                  // *** JOB TRACKING ***

                  if ($objType == "track_job") :

                     // Get stations delivered before current requested station requested by end customer
                     $sqlquery = "SELECT tr.tr_sort, tr.tr_status, tr.tr_finishtime, tr.tr_hsno,"
                               . "       ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country"
                               . "  FROM phoenix.tour AS tr, phoenix.address AS ad"
                               . "  WHERE tr.jb_id = '" . $objId . "' AND"
                               . "        tr.ad_id = ad.ad_id"
                               . "  ORDER BY tr.tr_sort";

                     $result = $db_conn->query($sqlquery);
                     if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());

                     while ($row = $result->fetch_assoc()):                          
                           $trOut .= "<tr>\n";
                           $trOut .= "  <td width=\"50%\" align=\"left\">\n";
                           $trOut .= "    <span class=\"f10np1\">" . $row["tr_sort"] . ". " . getLngt("Station") . "<br>\n";
                           $trOut .=        $row["ad_street"] . "&nbsp;" . $row["tr_hsno"] . "<br>\n";
                           $trOut .=        $row["ad_zipcode"] . "&nbsp;" . $row["ad_city"] . "\n";
                           $trOut .= "    </span>\n";
                           $trOut .= "  </td>\n";
                           $trOut .= "  <td width=\"20%\" align=\"left\">\n";
                           if ($row["tr_status"] == "1") :
                              $trOut .= "    <span class=\"f10np1_green\">" . getLngt("erledigt") . "</span>\n";
                           else :
                              $trOut .= "    <span class=\"f10np1_red\">" . getLngt("offen") . "</span>\n";
                           endif;
                           $trOut .= "  </td>\n";
                           $trOut .= "  <td width=\"30%\" align=\"left\">\n";
                           if ($row["tr_status"] == "1") :
                              $trOut .= "    <span class=\"f10np1\">" . formatOutput($row["tr_finishtime"],$outputFormatField["tr_finishtime"]) . "</span>\n";
                           endif;
                           $trOut .= "  </td>\n";
                           $trOut .= "</tr>\n";
                           $trOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
                     endwhile;
                     $result->free();
                  endif;


                  // ---------------------------------

                  // Get contractor (seller) data (e.g. Amazon) of the carrier (e.g. Stadtbote) for visualisation for the end customer
                  // Get process of all events of the tracking ID
                  $sqlquery = "SELECT cmp.cmp_comp, cmp.cmp_comp2, hq.hq_name, cmp2.cmp_comp AS cmp2_comp,"
                            . "       cmp2.cmp_comp2 AS cmp2_comp2, cmp2.cmp_logo AS cmp2_logo, cmp2.cmp_logo_width AS cmp2_logo_width, cmp2.cmp_logo_height AS cmp2_logo_height"
                            . "  FROM phoenix.job AS jb, phoenix.costcenter AS csc, phoenix.customer AS cs, phoenix.company AS cmp, phoenix.headquarters AS hq, phoenix.company AS cmp2"
                            . "  WHERE jb.jb_id = '" . $objId . "'   AND"
                            . "        jb.csc_id_payer = csc.csc_id AND"
                            . "        csc.cs_id = cs.cs_id         AND"
                            . "        cs.cmp_id = cmp.cmp_id       AND"
                            . "        cs.hq_id = hq.hq_id          AND"
                            . "        hq.cmp_id = cmp2.cmp_id";

                  $result = $db_conn->query($sqlquery);
                  if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());

                  while ($row = $result->fetch_assoc()):                          

//                        $cmpOut .= $row["cmp_comp"] . "&nbsp;" . $row["cmp_comp2"] . "<br>\n";
                        
                        /*
                        $cmpOut .= "<tr>\n";
                        $cmpOut .= "  <td align=\"left\">\n";
                        $cmpOut .= "    <span class=\"f12bp1\">" . $row["cmp_comp"] . "<br>" . $row["cmp_comp2"] . "</span>\n";
                        $cmpOut .= "  </td>\n";
                        $cmpOut .= "</tr>\n";
                        $cmpOut .= "<tr><td class=\"spacer15\"></td></tr>\n";
                        */

                        /*
                        $row["hq_name"]   $row["cmp2_logo"]   $row["cmp2_logo_width"]   $row["cmp2_logo_height"]

                        $cmp2Out .= "<tr>\n";
                        $cmp2Out .= "  <td align=\"center\">\n";
                        $cmp2Out .= "    <span class=\"f12bp1\">" . $row["cmp2_comp"] . "<br>" . $row["cmp2_comp2"] . "</span>\n";
                        $cmp2Out .= "  </td>\n";
                        $cmp2Out .= "</tr>\n";
                        $cmp2Out .= "<tr><td class=\"spacer15\"></td></tr>\n";
                        */
                  endwhile;
                  $result->free();

            else :
                  // Write logdata into log database
                  // writeToLogDB("97",$hqId,"","","","",$objId,"STATUS=OBJTYPE_NOT_FOUND|IP=" . $currentClientIP . "|MO_ID" . $moId);
            endif;

         else :
            // database not specified in metaobject row
            // writeToLogDB("97","","","","","","","STATUS=DB_NOT_SPECIFIED|IP=" . $currentClientIP . "|MO_ID" . $moId);
         endif;
      else :
         // HASH nicht gefunden um Zuordnung herzustellen
      endif;
   endif;
else :
   // Write logdata into log database
   // writeToLogDB("97","","","","","","","STATUS=EMPTY_OPCODE|IP=" . $currentClientIP . "|MO_ID" . $moId);
endif;
?>

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset="ISO-8859-1">

<title><?php echo $pageTitel ?></title>

<style type="text/css">


.mcTable { border:0px; width:650px; background:#CDD9FD; }

.mcTable2 { border:0px; width:610px; background:#CDD9FD; }

.spacer05 { height:5px; background:#CDD9FD;}
.spacer15 { height:15px; background:#CDD9FD;}
.spacer25 { height:25px; background:#CDD9FD;}

.f10np1       { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; padding: 1px; color: #000000;}
.f10bp1       { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold; padding: 1px; color: #000000;}
.f10np1_green { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; padding: 1px; color: #00BB00;}
.f10np1_red   { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; padding: 1px; color: #FF0000;}
.f10np1_blue  { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; padding: 1px; color: #1b12b9;}
.f12np1       { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: normal; padding: 1px; color: #000000;}
.f12bp1       { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold; padding: 1px; color: #000000;}
.f12np1_blue  { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: normal; padding: 1px; color: #1b12b9;}

</style>

<script type="text/javascript">
<!--

function finishTrackingPage() {
	document.forms[0].submit();
}

function selectLanguage(lng) {
	document.forms[0].selectedLanguage.value = lng;
	 finishTrackingPage();
}

-->
</script>

</head>

<body>

<form action="tracking.php" method="post">

<input type="hidden" name="f_act" value="">
<input type="hidden" name="trackingID" value="<?php echo $trackingID ?>">
<input type="hidden" name="selectedLanguage" value="<?php echo ec($selectedLanguage) ?>">

<center>
<table class="mcTable">
  <tr>
  	<td style="width:650px;" align="center">
  		<img src="../images/external/trck_header.jpg" border="0" height="167" width="640">
    </td>
  </tr>
</table>
<table class="mcTable"><tr><td class="spacer05"></td></tr></table>

<table class="mcTable">  
	<tr>
		<td style="width:20px;">			
		</td>
			<td style="width:305px;" align="left">
			<span class="f10np1"><a href="javascript:selectLanguage('0');"><?php echo getLngt("[Deutsch]") ?></a></span>&nbsp;
			<span class="f10np1"><a href="javascript:selectLanguage('1');"><?php echo getLngt("[English]") ?></a></span>
		</td>
		<td style="width:305px;" align="right">
			<!-- <span class="f10np1"><a href="javascript:finishTrackingPage();"><?php echo getLngt("[Anfrage senden]") ?></a></span> -->
		</td>
		<td style="width:20px;">			
		</td>
  </tr>
</table>
<table class="mcTable"><tr><td class="spacer25"></td></tr></table>

<table class="mcTable">  
	<tr>
		<td style="width:20px;">			
		</td>
		<td style="width:610px;" align="left">
			<span class="f12np1_blue"><?php echo getLngt("Sendungsnummer") ?>:</span>&nbsp;&nbsp;&nbsp;
			<input class="f12np1" type="text" name="trackingID" value="<?php echo $trackingID ?>">&nbsp;&nbsp;&nbsp;
			<span class="f10np1"><a href="javascript:finishTrackingPage();"><?php echo getLngt("[Anfrage senden]") ?></a></span>
		</td>
		<td style="width:20px;">
		</td>
  </tr>
</table>
<table class="mcTable"><tr><td class="spacer25"></td></tr></table>

<?php if ($csEndOut != "") : ?>
  <table class="mcTable">  
  	<tr>
  		<td style="width:20px;">
  		</td>
  		<td style="width:610px;" align="left">
  			<span class="f10np1_blue"><?php echo getLngt("Lieferadresse:") ?></span><br>
        <span class="f10np1"><?php echo $csEndOut ?></span>
  		</td>
  		<td style="width:20px;">
  		</td>
    </tr>
  </table>
  <table class="mcTable"><tr><td class="spacer25"></td></tr></table>
<?php endif; ?>

<?php if ($cmpOut != "") : ?>
  <table class="mcTable">  
  	<tr>
  		<td style="width:20px;">
  		</td>
  		<td style="width:610px;" align="left">
  			<span class="f10np1_blue"><?php echo getLngt("Lieferant:") ?></span><br>
        <span class="f10np1"><?php echo $cmpOut ?></span>
  		</td>
  		<td style="width:20px;">
  		</td>
    </tr>
  </table>
  <table class="mcTable"><tr><td class="spacer25"></td></tr></table>
<?php endif; ?>

<?php if ($tratpOut == "" && $trOut == "") : ?>
  <table class="mcTable">  
  	<tr>
  		<td style="width:20px;">
  		</td>
  		<td style="width:610px;" align="center">
        <span class="f10np1_red"><?php echo $out ?></span>
  		</td>
  		<td style="width:20px;">
  		</td>
    </tr>
  </table>
  <table class="mcTable"><tr><td class="spacer25"></td></tr></table>
<?php endif; ?>

<?php if ($tratpOut != "") : ?>
  <table class="mcTable">
  	<tr>
  		<td style="width:20px;">
  		</td>
  		<td style="width:610px;" align="center">
        <table class="mcTable2">
          <tr>
            <td width="50%" align="left">
              <span class="f10bp1"><?php echo getLngt("Ereignis") ?></span>
            </td>
            <td width="20%" align="left">
              <span class="f10bp1"><?php echo getLngt("Status") ?></span>
            </td>
            <td width="30%" align="left">
              <span class="f10bp1"><?php echo getLngt("Zeitpunkt") ?></span>
            </td>
          </tr>
          <tr><td class="spacer05" colspan="3"></td></tr>
          <?php echo $tratpOut ?>
        </table>
  		</td>
  		<td style="width:20px;">
  		</td>
    </tr>
  </table>
  <table class="mcTable"><tr><td class="spacer25"></td></tr></table>
<?php endif; ?>

<?php if ($trOut != "") : ?>
  <table class="mcTable">  
  	<tr>
  		<td style="width:20px;">
  		</td>
  		<td style="width:610px;" align="center">
        <table class="mcTable2">
          <tr>
            <td width="50%" align="left">
              <span class="f10bp1"><?php echo getLngt("Auslieferungsstationen") ?></span>
            </td>
            <td width="20%" align="left">
              <span class="f10bp1"><?php echo getLngt("Status") ?></span>
            </td>
            <td width="30%" align="left">
              <span class="f10bp1"><?php echo getLngt("Zeitpunkt") ?></span>
            </td>
          </tr>
          <tr><td class=\"spacer05\"></td></tr>
          <?php echo $trOut ?>
        </table>
  		</td>
  		<td style="width:20px;">
  		</td>
    </tr>
  </table>
  <table class="mcTable"><tr><td class="spacer15"></td></tr></table>
<?php endif; ?>

<table class="mcTable">
  <tr>
  	<td style="width:650px;" align="center">
  		<img src="../images/external/assecutor.png" border="0" height="51" width="640">
    </td>
  </tr>
</table>
</center>

</form>

</body>

</html>