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


include_once ("../include/mcglobal.inc.php");
include_once ("../include/inc_job.inc.php");
include_once ("../include/inc_tracking.inc.php");
include_once ("../locating/xServer.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__);

$debug = false;

$pageTitel = getLngt("Sendungsverfolgung");

// Init header image
$imgLogoFile = "assecutor.png";
$imgLogoHeight = "233";
$imgLogoWidth = "543";
$imgCssBackground = "#CDD9FD";

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

$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.");

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

   $tmpArray = getTrackingdataByID($trackingID);
   $objType = $tmpArray[0];
   $trackingArray = $tmpArray[1];   
   $trackingArrayLen = count($trackingArray);

   $atLeastOneTourArticleDoesExist = false;
   if ($trackingArray[0]["trat_id"] != "") :
      $atLeastOneTourArticleDoesExist = true;
   endif;

   if ($debug) : 
      print_r($trackingArray); echo "<br><br>";
      echo "objType = " . $objType . "<br>";
      echo "atLeastOneTourArticleDoesExist = " . ($atLeastOneTourArticleDoesExist ? "Yes" : "No") . "<br>";
      echo "languageSelected = " . $languageSelected . "<br>";
      echo "languageDBUpdateMode = " . $languageDBUpdateMode . "<br>";
   endif;

   if ($trackingArrayLen > 0) :

       // LAYOUT DATA
       $currentHqId = $trackingArray[0]["hq_id"];
       if ($currentHqId == "") : $currentHqId = "0"; endif;       
       $jbCscIdPayer = $trackingArray[0]["csc_id_payer"];
       if ($jbCscIdPayer > 0) :
          $jbCsIdPayer = getFieldValueFromId("costcenter","csc_id",$jbCscIdPayer,"cs_id");
          if ($jbCsIdPayer > 0) :
             $jbCsBlurMarkupTimePayer = getFieldValueFromId("customer","cs_id",$jbCsIdPayer,"cs_blur_markup_time");
             if ($jbCsBlurMarkupTimePayer == "") : $jbCsBlurMarkupTimePayer = 0; endif;
             $jbCmpIdPayer = getFieldValueFromId("customer","cs_id",$jbCsIdPayer,"cmp_id");
             $jbCmpCompPayer = getFieldValueFromId("company","cmp_id",$jbCmpIdPayer,"cmp_comp");
          endif;
       endif;

       $parLogoFile = getParameterValue("0", "IMG_LOGO_NAME_EMAIL", $currentHqId, "0");
       $parLogoHeight = getParameterValue("0", "IMG_LOGO_HEIGHT", $currentHqId, "0");
       $parLogoWidth = getParameterValue("0", "IMG_LOGO_WIDTH", $currentHqId, "0");
       $parCssBackground = getParameterValue("0", "IMG_LOGO_BGCOL_EMAIL", $currentHqId, "0");
       if ($parLogoFile != "") :
          $imgLogoFile = $parLogoFile; 
          $imgLogoHeight = $parLogoHeight;
          $imgLogoWidth = $parLogoWidth;
       endif;
       if ($parCssBackground != "") : 
          $imgCssBackground = $parCssBackground;
       endif;
       if ($debug) : 
          echo "imgLogoFile = " . $imgLogoFile . "<br>";
          echo "imgLogoHeight = " . $imgLogoHeight . "<br>";
          echo "imgLogoWidth = " . $imgLogoWidth . "<br>";
          echo "imgCssBackground = " . $imgCssBackground . "<br>";
       endif;
       

       // HEADER
       if ($objType == "tracking_jb" || $objType == "track_jb") :

          $mapViewLink = "[<a href=\"../locating/map.php?jb_id=" . $trackingArray[0]["jb_id"] . "&tracking=" . $trackingID . "\" target=\"_blank\">" . getLngt("Karte") . "</a>]";

          $historyOut .= "<tr>\n";
          $historyOut .= "  <td align=\"center\" colspan=\"5\">\n";
          $historyOut .= "    <span class=\"f12bp1_darkgreen\">" . getLngt("Auftrag") . ": " . $trackingArray[0]["jb_id"]  . "</span>" . "&nbsp;&nbsp;" . $mapViewLink . "\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "</tr>\n";
          $historyOut .= "<tr><td class=\"spacer25\"></td></tr>\n";

          $historyOut .= "<tr>\n";
          $historyOut .= "  <td width=\"50%\" align=\"left\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Station") . "</span><br>\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "  <td width=\"20%\" align=\"left\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Status") . "</span>\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "  <td width=\"30%\" align=\"left\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Erledigungszeit") . "</span>\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "</tr>\n";
          $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";

/*
          $historyOut .= "<tr>\n";
          $historyOut .= "  <td align=\"left\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Station") . "</span>\n";
          $historyOut .= "  </td>\n";
          // $historyOut .= "  <td align=\"center\">\n";
          // $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Artikel") . "</span>\n";
          // $historyOut .= "  </td>\n";
          $historyOut .= "  <td align=\"center\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Erledigungszeit") . "</span>\n";
          $historyOut .= "  </td>\n";
          // $historyOut .= "  <td align=\"center\">\n";
          // $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Ereignis") . "</span>\n";
          // $historyOut .= "  </td>\n";
          // $historyOut .= "  <td align=\"left\">\n";
          // $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Bemerkung") . "</span>\n";
          // $historyOut .= "  </td>\n";
          $historyOut .= "</tr>\n";
          $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
*/

       elseif ($objType == "tracking_tr" || $objType == "track_tr") :

          $currAddress = $trackingArray[0]["ad_street"] . " " . $trackingArray[0]["tr_hsno"] . " in " . $trackingArray[0]["ad_zipcode"] . " " . $trackingArray[0]["ad_city"];
          $trComp = $trackingArray[0]["tr_comp"];

          // ETA
          $etaOut = "";
          if ($trackingArray[0]["tr_status"] == "1") :
             $etaOut = getLngt("Ihre Sendung wurde geliefert.");
          else :
             $etaOffset = get_tour_duration($trackingArray[0]["tr_id"]);
             $roundToXMinutes = 5;
// $etaOffset = -1;
// echo $etaOffset . "<br><br>";
             if (is_numeric($etaOffset)) :
                if ($etaOffset != -1) :

                   // ETA
                   $currUnixTimestamp = time();
                   if ($roundToXMinutes != "" && is_numeric($roundToXMinutes) && $roundToXMinutes > 1) :
                      $eta = (floor(($currUnixTimestamp + $etaOffset) / 60) - (floor(($currUnixTimestamp + $etaOffset) / 60) % $roundToXMinutes)) * 60;  // Full x minutes (e.g. 5)
                   else :
                      $eta = floor(($currUnixTimestamp + $etaOffset) / 60) * 60;  // Full minute
                   endif;
                   $etaTime = date("H:i", $eta);

                   if ($jbCsBlurMarkupTimePayer > 0) :

                      // Time window
                      $etaTimeLowerRange = date("H:i", $eta - ($jbCsBlurMarkupTimePayer * 60));
                      $etaTimeUpperRange = date("H:i", $eta + ($jbCsBlurMarkupTimePayer * 60));

                      $etaOut .= getLngt("Ihre Sendung von") . " " . $jbCmpCompPayer . " " . getLngt("wird voraussichtlich zwischen") . "<br><br>";
                      $etaOut .= "<span class=\"f12bp1_blue\">" . $etaTimeLowerRange . " " . getLngt("Uhr") . " " . getLngt("und") . " " . $etaTimeUpperRange . " " . getLngt("Uhr") . "</span><br><br>";
                      $etaOut .= getLngt("bei") . " " . $trComp . " " . "<br><br>";
                      $etaOut .= "<b>" . $currAddress . " </b><br><br>";
                      $etaOut .= getLngt("eintreffen") . "." . "<br><br>";
                   else :

                      $etaOut .= getLngt("Ihre Sendung von") . " " . $jbCmpCompPayer . " " . getLngt("wird voraussichtlich um ca.") . "<br><br>";
                      $etaOut .= "<span class=\"f12bp1_blue\">" . $etaTime . " " . getLngt("Uhr") . "</span><br><br>";
                      $etaOut .= getLngt("bei") . " " . $trComp . " " . "<br><br>";
                      $etaOut .= "<b>" . $currAddress . " </b><br><br>";
                      $etaOut .= getLngt("eintreffen") . "." . "<br><br>";
                   endif;
                else :
                   // $etaOut = getLngt("Derzeit steht technisch leider keine zeitliche Einschätzung bereit.");
                  
                   $hqAdmin = getFieldValueFromId("headquarters","hq_id",$currentHqId,"hq_admin");
                   $hqUsrId = getFieldValueFromId("employee","emp_id",$hqAdmin,"usr_id");
                   $hqUsrPhone = getFieldValueFromId("user","usr_id",$hqUsrId,"usr_phone");

                   $etaOut .= getLngt("Ihre Sendung von") . " " . $jbCmpCompPayer . "<br><br>";
                   $etaOut .= getLngt("an") . " " . $trComp . " " . "<br><br>";
                   $etaOut .= "<b>" . $currAddress . " </b><br><br><br><br>";
                   $etaOut .= getLngt("Dieser Service steht aus technischen Gründen") . "<br><br>";
                   $etaOut .= getLngt("momentan leider nicht zur Verfügung") . "." . "<br><br>";
                   $etaOut .= getLngt("Bitte probieren sie es etwas später noch einmal") . "<br><br>";
                   $etaOut .= getLngt("oder wenden sie sich telefonisch an") . ":" . "<br><br><br>";
                   $etaOut .= "<span class=\"f12bp1_blue\">" . $hqUsrPhone . "</span><br><br>";
                endif;
             endif;
          endif;

          $classTrStatus = "f12bp1_red";
          if ($trackingArray[0]["tr_status"] == "1") : 
             $classTrStatus = "f12bp1_darkgreen";
          endif;

          /*
          $historyOut .= "<tr>\n";
          $historyOut .= "  <td align=\"center\" colspan=\"4\">\n";
          // $historyOut .= "    <span class=\"" . $classTrStatus . "\">" . $currAddress  . "</span>\n";
          $historyOut .= "    <span class=\"f12bp1_darkgreen\">" . $currAddress  . "</span>\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "</tr>\n";
          $historyOut .= "<tr><td class=\"spacer25\"></td></tr>\n";
          */
          $historyOut .= "<tr><td class=\"spacer25\"></td></tr>\n";

          
          if ($etaOut != "") :
             $historyOut .= "<tr>\n";
             $historyOut .= "  <td align=\"center\" colspan=\"4\">\n";
             // $historyOut .= "    <span class=\"" . $classTrStatus . "\">" . $etaOut  . "</span>\n";
             $historyOut .= "    <span class=\"f10np1_blue\">" . $etaOut  . "</span>\n";
             $historyOut .= "  </td>\n";
             $historyOut .= "</tr>\n";
             $historyOut .= "<tr><td class=\"spacer25\"></td></tr>\n";
             $historyOut .= "<tr><td class=\"spacer25\"></td></tr>\n";
          endif;

          if ($atLeastOneTourArticleDoesExist) :
             $historyOut .= "<tr>\n";
             $historyOut .= "  <td align=\"center\">\n";
             $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Artikel") . "</span>\n";
             $historyOut .= "  </td>\n";
             $historyOut .= "  <td align=\"center\">\n";
             $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Ereigniszeit") . "</span>\n";
             $historyOut .= "  </td>\n";
             $historyOut .= "  <td align=\"center\">\n";
             $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Ereignis") . "</span>\n";
             $historyOut .= "  </td>\n";
             $historyOut .= "  <td align=\"left\">\n";
             $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Bemerkung") . "</span>\n";
             $historyOut .= "  </td>\n";
             $historyOut .= "</tr>\n";
             $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
          endif;

       elseif ($objType == "tracking_trat" || $objType == "track_trat") :

          if ($trackingArray[0]["trat_serialno"] != "") :
             $historyOut .= "<tr>\n";
             $historyOut .= "  <td align=\"center\" colspan=\"3\">\n";
             $historyOut .= "    <span class=\"f12bp1_darkgreen\">" . "Sendung" . ": " . $trackingArray[0]["trat_serialno"]  . "</span>\n";
             $historyOut .= "  </td>\n";
             $historyOut .= "</tr>\n";
             $historyOut .= "<tr><td class=\"spacer25\"></td></tr>\n";
          endif;

          $historyOut .= "<tr>\n";
          $historyOut .= "  <td align=\"center\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Ereigniszeit") . "</span>\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "  <td align=\"center\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Ereignis") . "</span>\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "  <td align=\"left\">\n";
          $historyOut .= "    <span class=\"f10bp1\">" . getLngt("Bemerkung") . "</span>\n";
          $historyOut .= "  </td>\n";
          $historyOut .= "</tr>\n";
          $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
       endif;


       // BODY
       $remAddress = "";
       $remTratSerialno = "";
       for ($i = 0; $i < $trackingArrayLen; $i++) :

           $currAddress = $trackingArray[$i]["ad_street"] . " " . $trackingArray[$i]["tr_hsno"] . "<br>" . $trackingArray[$i]["ad_zipcode"] . " " . $trackingArray[$i]["ad_city"];

           if ($currAddress == $remAddress) :
              $currAddress = "";
           else :
              $remAddress = $currAddress;
           endif;

           $currTratSerialno = $trackingArray[$i]["trat_serialno"];
           if ($currTratSerialno == $remTratSerialno) :
              $currTratSerialno = "";
           else :
              $remTratSerialno = $currTratSerialno;
           endif;

           if ($objType == "tracking_jb" || $objType == "track_jb") :

              $classTrStatus = "f10np1_red";
              if ($trackingArray[$i]["tr_status"] == "1") : 
                 $classTrStatus = "f10np1_darkgreen";
              endif;

              $historyOut .= "<tr>\n";
              $historyOut .= "  <td width=\"50%\" align=\"left\">\n";
              $historyOut .= "    <span class=\"f10np1\">" . ($i + 1) . ". " . getLngt("Station") . "<br>\n";
              $historyOut .=        $currAddress;
              $historyOut .= "    </span>\n";
              $historyOut .= "  </td>\n";
              $historyOut .= "  <td width=\"20%\" align=\"left\">\n";
              if ($trackingArray[$i]["tr_status"] == "1") :
                 $historyOut .= "    <span class=\"f10np1_green\">" . getLngt("erledigt") . "</span>\n";
              else :
                 $historyOut .= "    <span class=\"f10np1_red\">" . getLngt("offen") . "</span>\n";
              endif;
              $historyOut .= "  </td>\n";
              $historyOut .= "  <td width=\"30%\" align=\"left\">\n";
              if ($trackingArray[$i]["tr_status"] == "1") :
                 $historyOut .= "    <span class=\"f10np1\">" . formatOutput($trackingArray[$i]["tr_finishtime"],$outputFormatField["tr_finishtime"]) . "</span>\n";
              endif;
              $historyOut .= "  </td>\n";
              $historyOut .= "</tr>\n";
              $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
/*
              if (false && $trackingArray[$i]["trat_serialno"] != "") :
                 $historyOut .= "<tr>\n";
                 $historyOut .= "  <td align=\"left\">\n";
                 $historyOut .= "    <span class=\"" . $classTrStatus . "\">" . $currAddress . "</span>\n";
                 $historyOut .= "  </td>\n";
                 // $historyOut .= "  <td align=\"center\">\n";
                 // $historyOut .= "    <span class=\"f10np1\">" . $currTratSerialno . "</span>\n";
                 // $historyOut .= "  </td>\n";
                 $historyOut .= "  <td align=\"center\">\n";
                 $historyOut .= "    <span class=\"f10np1\">" . formatOutput($trackingArray[$i]["tr_finishtime"],$outputFormatField["tr_finishtime"]) . "</span>\n";
                 $historyOut .= "  </td>\n";
                 // $historyOut .= "  <td align=\"center\">\n";
                 // $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["mt_value"] . "</span>\n";
                 // $historyOut .= "  </td>\n";
                 // $historyOut .= "  <td align=\"left\">\n";
                 // $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["tratp_remark"] . "</span>\n";
                 // $historyOut .= "  </td>\n";
                 $historyOut .= "</tr>\n";
                 $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
              endif;
*/
           elseif ($objType == "tracking_tr" || $objType == "track_tr") :

              // Check there is at least one tour article
              if ($atLeastOneTourArticleDoesExist) :
                 if ($trackingArray[$i]["trat_serialno"] != "") :
                    $historyOut .= "<tr>\n";
                    $historyOut .= "  <td align=\"center\">\n";
                    $historyOut .= "    <span class=\"f10np1\">" . $currTratSerialno . "</span>\n";
                    $historyOut .= "  </td>\n";
                    $historyOut .= "  <td align=\"center\">\n";
                    $historyOut .= "    <span class=\"f10np1\">" . formatOutput($trackingArray[$i]["tratp_createtime"],$outputFormatField["tratp_createtime"]) . "</span>\n";
                    $historyOut .= "  </td>\n";
                    $historyOut .= "  <td align=\"center\">\n";
                    $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["mt_value"] . "</span>\n";
                    $historyOut .= "  </td>\n";
                    $historyOut .= "  <td align=\"left\">\n";
                    $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["tratp_remark"] . "</span>\n";
                    $historyOut .= "  </td>\n";
                    $historyOut .= "</tr>\n";
                    $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
                 endif;
              endif;

           elseif ($objType == "tracking_trat" || $objType == "track_trat") :

              $historyOut .= "<tr>\n";
              $historyOut .= "  <td align=\"center\">\n";
              $historyOut .= "    <span class=\"f10np1\">" . formatOutput($trackingArray[$i]["tratp_createtime"],$outputFormatField["tratp_createtime"]) . "</span>\n";
              $historyOut .= "  </td>\n";
              $historyOut .= "  <td align=\"center\">\n";
              $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["tratp_state"] . "</span>\n";
              $historyOut .= "  </td>\n";
              $historyOut .= "  <td align=\"left\">\n";
              $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["tratp_remark"] . "</span>\n";
              $historyOut .= "  </td>\n";
              $historyOut .= "</tr>\n";
              $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
           endif;

           /*
           $historyOut .= "<tr>\n";
           $historyOut .= "  <td width=\"30%\" align=\"left\">\n";
           $historyOut .= "    <span class=\"f10np1\">" . formatOutput($trackingArray[$i]["tratp_createtime"],$outputFormatField["tratp_createtime"]) . "</span>\n";
           $historyOut .= "  </td>\n";
           $historyOut .= "  <td width=\"50%\" align=\"left\">\n";
           $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["mt_value"] . "</span>\n";
           $historyOut .= "  </td>\n";
           $historyOut .= "  <td width=\"20%\" align=\"left\">\n";
           $historyOut .= "    <span class=\"f10np1\">" . $trackingArray[$i]["tratp_state"] . "</span>\n";
           $historyOut .= "  </td>\n";
           $historyOut .= "</tr>\n";
           $historyOut .= "<tr><td class=\"spacer05\"></td></tr>\n";
           */
       endfor;

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

       // 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->fetchRow()):                          

             // $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();
*/

   endif;
endif;
?>

<html>

<head>

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

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

<style type="text/css">

<?php if (true) : ?>
.mcTable { border:0px; width:650px; background:<?php echo $imgCssBackground ?>; }
.mcTable2 { border:0px; width:610px; background:<?php echo $imgCssBackground ?>; }
<?php endif; ?>

.spacer05 { height:5px; background:<?php echo $imgCssBackground ?>;}
.spacer15 { height:15px; background:<?php echo $imgCssBackground ?>;}
.spacer25 { height:25px; background:<?php echo $imgCssBackground ?>;}
.spacer50 { height:50px; background:<?php echo $imgCssBackground ?>;}

.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_darkgreen { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; padding: 1px; color: #008800;}
.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;}
.f12bp1_red       { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold; padding: 1px; color: #FF0000;}
.f12bp1_darkgreen { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold; padding: 1px; color: #008800;}
.f12np1_blue      { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: normal; padding: 1px; color: #1b12b9;}
.f12bp1_blue      { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold; 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_ADSG.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">
  		<br><img src="../images/external/<?php echo $imgLogoFile; ?>" border="0" height="<?php echo $imgLogoHeight; ?>" width="<?php echo $imgLogoWidth; ?>">  		
    </td>
  </tr>
</table>
<table class="mcTable"><tr><td class="spacer05"></td></tr></table>
<?php if (false) : ?>
<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 type="text" name="trackingID" value="<?php echo $trackingID ?>" size="35">&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 endif; ?>

<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 ($historyOut == "" && $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 ($historyOut != "") : ?>
  <table class="mcTable">
  	<tr>
  		<td style="width:20px;">
  		</td>
  		<td style="width:610px;" align="center">
        <table class="mcTable2">

          <?php echo $historyOut ?>
        </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; ?>
<?php if (true) : ?>
<table class="mcTable"><tr><td class="spacer50"></td></tr></table>
<table class="mcTable"><tr><td class="spacer50"></td></tr></table>
<table class="mcTable">
  <tr>
  	<td style="width:650px;" align="center">
  		<img src="../images/external/adsg_footer_transparent.png" border="0" height="70" width="210">
    </td>
  </tr>
</table>
<table class="mcTable"><tr><td class="spacer15"></td></tr></table>
<?php endif; ?>
</center>

</form>

</body>

</html>