<?php
/*=======================================================================
 *
 * job_tour.php
 *
 * Autor: Carsten Annacker
 *
 =======================================================================*/

include_once("../include/global.inc.php");
include_once("../include/caglobal.inc.php");
list ($hq_id_job) = getHttpVars(array("hq_id_job"));
include_once("../include/auth.inc.php");
include_once("../jobs/job_accesskeys.inc.php");
include_once ("../admin/menu.php");

//list ($csc_id_orderer) =
  getSecHttpVars("1", array("csc_id_orderer"));
if ($csc_id_orderer == "" && $csc_id_orderer != '0') reportDie ("$PHP_SELF: Parameter 'csc_id_orderer' fehlt!", false);
$cs_id = getFieldValueFromId("costcenter", "csc_id", "$csc_id_orderer", "cs_id");
$csc_id_sel = $csc_id_orderer;
$von_csc_id_options = addOptionsFromTable("costcenter, costcenteraddress",
  "costcenter.csc_id", "costcenter.csc_name", "costcenter.csc_name",
  "costcenter.csc_id = costcenteraddress.csc_id AND " .
  "costcenter.cs_id = '$cs_id' AND costcenteraddress.adt_id = '4'", $csc_id_sel);
$nach_csc_id_options = addOptionsFromTable("costcenter, costcenteraddress",
  "costcenter.csc_id", "costcenter.csc_name", "costcenter.csc_name",
  "costcenter.csc_id = costcenteraddress.csc_id AND " .
  "costcenter.cs_id = '$cs_id' AND costcenteraddress.adt_id = '4'");

$_von_csc_id_options_ = $von_csc_id_options;
$_nach_csc_id_options_ = $nach_csc_id_options;
if (getParameterValue($emp_id, "MODE_LATER_JOB") == "1"):
  $EMP_MODE_LATERJOB_START = "";
  $EMP_MODE_LATERJOB_END = "";
else:
  $EMP_MODE_LATERJOB_START = "<!--";
  $EMP_MODE_LATERJOB_END = "-->";
endif;

if (MASK_CASH_PAYER_SELECT != "1"):
  $PAYER_TEXT = "Rechnungszahler";
  $COSTSPLIT_TEXT = "Kosten werden aufgeteilt";
  $COSTSPLIT_TITLE = "Kosten splitten";
else:
  $PAYER_TEXT = "Bezahler";
  $COSTSPLIT_TEXT = "Rechnungszahlung";
  $COSTSPLIT_TITLE = "Rechnung an Bezahler";
endif;

$JB_CASHPAYER_MAIL_DISABLED_START = "<!--";
$JB_CASHPAYER_MAIL_DISABLED_END = "-->";
$sqlquery = "SELECT cs.cs_jbstatusmail, cs.cs_jbstatusmail2, cs.cs_jbstatusmail3"
          . " FROM costcenter AS csc, customer AS cs"
          . " WHERE csc.csc_id = " . getParameterValue("0", "CSC_ID_PAYER_CASH", $hq_id) . " AND csc.cs_id = cs.cs_id";
$res = $db->query($sqlquery);
//$fileHandle = @fopen("../log/job_tour_" . $today['year'] . sprintf("%02d", $today['mon']) . ".log", 'a');
//@fwrite($fileHandle, "[" . date("Y-m-d H:i:s") . "] \$sqlquery = " . $sqlquery . "\n");
//@fclose($fileHandle);
if (DB::isError($res)) reportDie ("$PHP_SELF: '$sqlquery': " . $res->getMessage());
$cs_jbstatusmailstr = "";
if ($row =($phpVersion >= "8.0" ? $res->fetch_assoc() : $res->fetchRow())):
  if ($row["cs_jbstatusmail3"] == "1")
    $cs_jbstatusmailstr .= "Erf.";
  if ($row["cs_jbstatusmail2"] == "1")
    $cs_jbstatusmailstr .= ($cs_jbstatusmailstr == "" ? "" : "/") . "Abh.";
  if ($row["cs_jbstatusmail"] == "1")
    $cs_jbstatusmailstr .= ($cs_jbstatusmailstr == "" ? "" : "/") . "Erl.";
  if ($cs_jbstatusmailstr != "") {
    $cs_jbstatusmailstr = "Mail (" . $cs_jbstatusmailstr . ")";
    $JB_CASHPAYER_MAIL_DISABLED_START = "";
    $JB_CASHPAYER_MAIL_DISABLED_END = "";
  }
endif;
$res->free();

$CUSTOMER_DISABLED_START = "";
$CUSTOMER_DISABLED_END = "";

$PHOTO_DISABLED_START = "";
$PHOTO_DISABLED_END = "";
if (MASK_TR_PHOTO != "1"):
  $PHOTO_DISABLED_START = "<!--";
  $PHOTO_DISABLED_END = "-->";
endif;

$MASK_CUSTOMER_PRICEQUERY_DISABLED_START = "";
$MASK_CUSTOMER_PRICEQUERY_DISABLED_END = "";
if (MASK_CUSTOMER_SHOW_PRICEQUERY != "1"):
  $MASK_CUSTOMER_PRICEQUERY_DISABLED_START = "<!--";
  $MASK_CUSTOMER_PRICEQUERY_DISABLED_END = "-->";
endif;

$_TOURNOVALSIZE_ = (MASK_MAXTOUR > 10 ? 2 : 1);

// *** TABINDICES ***
$_origin1_tabindex_ = "";
$_origin2_tabindex_ = "";
$_origin3_tabindex_ = "";
$_origin4_tabindex_ = "";
$_origin5_tabindex_ = "";
$_origin6_tabindex_ = "";
$_origin7_tabindex_ = "";
$ti = 0;
$_von_cs_comp_tabindex_ = ++$ti;
$_von_tr_person_tabindex_ = ++$ti;
$_von_ad_street_tabindex_ = ++$ti;
$_von_tr_hsno_tabindex_ = ++$ti;
$_von_ad_country_tabindex_ = "";
$_von_ad_zipcode_tabindex_ = ++$ti;
$_von_ad_city_tabindex_ = ++$ti;
$_von_tr_remark_tabindex_ = ++$ti;
$_nach_cs_comp_tabindex_ = ++$ti;
$_nach_tr_person_tabindex_ = ++$ti;
$_nach_ad_street_tabindex_ = ++$ti;
$_nach_tr_hsno_tabindex_ = ++$ti;
$_nach_ad_country_tabindex_ = "";
$_nach_ad_zipcode_tabindex_ = ++$ti;
$_nach_ad_city_tabindex_ = ++$ti;
$_nach_tr_remark_tabindex_ = ++$ti;
$_von_tr_commission_no_tabindex_ = ++$ti;
$_von_tr_commission_no_accesskey_ = _VON_TR_COMMISSION_NO_ACCESSKEY_;
$_nach_tr_commission_no_tabindex_ = ++$ti;
$_nach_tr_commission_no_accesskey_ = _NACH_TR_COMMISSION_NO_ACCESSKEY_;
$_jb_orderer_tabindex_ = ++$ti;
$_jb_commission_no_tabindex_ = ++$ti;
$_nach_tr_tracking_tabindex_ = ++$ti;
$_von_tr_tracking_tabindex_ = ++$ti;
$_tr_photo_von_tabindex_ = ++$ti;
$_tr_ware_from_von_tabindex_ = ++$ti;
$_tr_ware_to_von_tabindex_ = ++$ti;
$_tr_ware_from_nach_tabindex_ = ++$ti;
$_tr_ware_to_nach_tabindex_ = ++$ti;
$_tr_photo_nach_tabindex_ = ++$ti;
$_payer_from_tabindex_ = ++$ti;
$_payer_to_tabindex_ = ++$ti;
$_vonFirmaButton_tabindex_ = ++$ti;
$_vonFirmaButton_accesskey_ = _VONFIRMABUTTON_ACCESSKEY_;
$_vonAdressButton_tabindex_ = ++$ti;
$_vonAdressButton_accesskey_ = _VONADRESSBUTTON_ACCESSKEY_;
$_von_tr_mediationarea_id_Button_tabindex_ = "";
$_von_tr_remark_Button_tabindex_ = ++$ti;
$_von_tr_remark_Button_accesskey_ = _VON_TR_REMARK_BUTTON_ACCESSKEY_;
$_hide_von_tr_remark_tabindex_ = ++$ti;
$_nachFirmaButton_tabindex_ = ++$ti;
$_nachFirmaButton_accesskey_ = _NACHFIRMABUTTON_ACCESSKEY_;
$_nachAdressButton_tabindex_ = ++$ti;
$_nachAdressButton_accesskey_ = _NACHADRESSBUTTON_ACCESSKEY_;
$_nach_tr_mediationarea_id_Button_tabindex_ = "";
$_hide_nach_tr_remark_tabindex_ = ++$ti;
$_nach_tr_remark_Button_tabindex_ = ++$ti;
$_nach_tr_remark_Button_accesskey_ = _NACH_TR_REMARK_BUTTON_ACCESSKEY_;
$_Berichte_tabindex_ = "";
$_Dokumente_tabindex_ = "";
$_bezahlerFirmaButton_tabindex_ = ++$ti;
$_bezahlerFirmaButton_accesskey_ = _BEZAHLERFIRMABUTTON_ACCESSKEY_;
$_jb_cash_tabindex_ = ++$ti;
$_jb_cash_accesskey_ = "";
$_jb_costsplit_tabindex_ = ++$ti;
$_jb_costsplit_accesskey_ = "";
$_accept_all_addresses_tabindex_ = ++$ti;
$_accept_all_addresses_accesskey_ = _ACCEPT_ALL_ADDRESSES_ACCESSKEY_;
$_jb_cashpayer_mail_tabindex_ = ++$ti;
$_jb_offer_mail_tabindex_ = ++$ti;
$_prevButton_tabindex_ = ++$ti;
$_prevButton_accesskey_ = _PREVBUTTON_ACCESSKEY_;
$_waste1Button_tabindex_ = ++$ti;
$_waste1Button_accesskey_ = _WASTE1BUTTON_ACCESSKEY_;
$_switchButton_tabindex_ = ++$ti;
$_switchButton_accesskey_ = _SWITCHBUTTON_ACCESSKEY_;
$_waste2Button_tabindex_ = ++$ti;
$_waste2Button_accesskey_ = _WASTE2BUTTON_ACCESSKEY_;
$_nextButton_tabindex_ = ++$ti;
$_nextButton_accesskey_ = _NEXTBUTTON_ACCESSKEY_;
$_searchOldJobButton_tabindex_ = ++$ti;
//$_searchOldJobButton_accesskey_ = _SEARCHOLDJOBBUTTON_ACCESSKEY_;
$_duplicateJobButton_tabindex_ = ++$ti;
$_getLastJobButton_tabindex_ = ++$ti;
$_duplicateJobButton_accesskey_ = _DUPLICATEJOBBUTTON_ACCESSKEY_;
$_jb_freetextButton_tabindex_ = ++$ti;
$_jb_freetextButton_accesskey_ = _JB_FREETEXTBUTTON_ACCESSKEY_;
$_jb_hiddenFreetextButton_tabindex_ = ++$ti;
// *** ***

//include("..\jobs\shrink.inc.php");
//$html_code = $tpl->get();
//echo htmlShrink($html_code, true);

?>

<html>
<head>
<title>AUFTRAGSERFASSUNG - DATENEINGABE</title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css.php">
<link rel="stylesheet" href="https://uplman.assecutor.net/assets/css/modal.css" type="text/css">
<?php include_once ("../include/js_framework.inc.php"); ?>
<style>
.cmp_remark
  { border: 0; width: 40em; height: 20em; background: rgba(0, 0, 0, 0); font-size: 9pt }
.cmp_remark_payer
  { border: 0; width: 40em; height: 20em; background: rgba(0, 0, 0, 0); font-size: 9pt }
.cmp_remark_small
  { border: 0; width: 40em; height: 10em; background: rgba(0, 0, 0, 0); font-size: 9pt }
.cmp_remark_payer_small
  { border: 0; width: 40em; height: 10em; background: rgba(0, 0, 0, 0); font-size: 9pt }

        h1 { font-size: 1.5rem; font-weight: 700; }
        p { color: #64748b; font-size: 0.9rem; }
        /* Overlay */
        #geocords-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            backdrop-filter: blur(4px);
            z-index: 9999;
            justify-content: center;
            align-items: center;
        }
        #geocords-overlay.active { display: flex; }
        #geocords-overlay iframe {
            width: 90vw;
            height: 85vh;
            border: none;
            border-radius: 16px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
        }
</style>
<script src="../include/lib_global.js" type="text/javascript"></script>
<script src="../include/key_events_content.js" language="JavaScript1.2" type="text/javascript"></script>
<script for="document" event="onkeydown()" language="JScript" type="text/jscript">
<!--
{
if(window.event.altKey&&event.keyCode>=49&&event.keyCode<=57){
actionMapEvent(window.event,event.keyCode);
}
}
//-->
</script>
<script type="text/javascript">
<!--
var job_tour_isLoading=true;
var cmp_remark_style="cmp_remark";
var cmp_remark_payer_style="cmp_remark_payer";
if (screen.height < 1080){
  cmp_remark_style="cmp_remark_small";
  cmp_remark_payer_style="cmp_remark_payer_small";
}
-->
</script>
<script src="../include/maps.googleapis.com_maps_api_js_places.php" async defer></script>
<script>
let autocomplete1;
let autocomplete2;
function initAutocomplete1(i) {
  if (typeof google == 'undefined') {
    if (i < 10)
      self.setTimeout('initAutocomplete1(' + (i+1) + ')', 100);
    return;
  }
  autocomplete1 = new google.maps.places.Autocomplete(
    document.getElementById('von_autocomplete'),
    {
      types: ['address'],
//      componentRestrictions: {'country': ['DE']},
      fields: ["geometry", "address_components", "types"]
    });

//    autocomplete.setFields('address_components');
  autocomplete1.addListener('place_changed', fillInAddress1);
  initAutocomplete2();
}

function initAutocomplete2() {
  autocomplete2 = new google.maps.places.Autocomplete(
    document.getElementById('nach_autocomplete'),
    {
      types: ['address'],
//      componentRestrictions: {'country': ['DE']},
      fields: ["geometry", "address_components", "types"]
    });

//    autocomplete.setFields('address_components');
  autocomplete2.addListener('place_changed', fillInAddress2);
}

// JQuery.Request (GET)
function ajaxRequestGetAsync(url, data) {
  $.ajax({
     type: "GET",
     url: url,
     data: data,
     async: true,
     cache: false,
     success: function(msg){eval(msg);}
  });
}

function fillInAddress1() {
  fillInAddress(1);
}

function fillInAddress2() {
  fillInAddress(2);
}

function fillInAddress(side) {
  // Get the place details from the autocomplete object.
  let place;
  if (side == 1)
    place = autocomplete1.getPlace();
  if (side == 2)
    place = autocomplete2.getPlace();
  if (!place.geometry)
    return;

//console.log(place.types);
  let accuracy = 0;
  const sufficient_types = ["intersection", "street_address", "premise", "subpremise"];
  const sufficient_types_accuracy = [7, 8, 9, 9];

  let type_index = -1;
  for (const type of place.types) {
    type_index = sufficient_types.indexOf(type);
    if (type_index > -1) {
      if (accuracy < sufficient_types_accuracy[type_index])
        accuracy = sufficient_types_accuracy[type_index];
    }
  }
//  let address1 = "";
//  let postcode = "";
  let route = "";
  let street_number = "";
  let country = "";
  let postal_code = ""
  let locality = "";
  let lat = 0;
  let lng = 0;

  if (type_index > -1) {
//console.log(place.geometry.location.lat());
//console.log(place.geometry.location.lng());
    lat = place.geometry.location.lat();
    lng = place.geometry.location.lng();
  }

  // Get each component of the address from the place details,
  // and then fill-in the corresponding field on the form.
  // place.address_components are google.maps.GeocoderAddressComponent objects
  // which are documented at http://goo.gle/3l5i5Mr
  for (const component of place.address_components) {
    let postal_code_dirty = false;
    // @ts-ignore remove once typings fixed
console.log(component);
    for (const componentType of component.types) {
//console.log(componentType);
      switch (componentType) {
        case "route": {
          route = component.short_name;
          if (side == 1)
            document.getElementsByName('von_ad_street')[0].value = component.short_name;
          if (side == 2)
            document.getElementsByName('nach_ad_street')[0].value = component.short_name;
          break;
        }

        case "street_number": {
          street_number = component.short_name;
          if (side == 1)
            document.getElementsByName('von_tr_hsno')[0].value = component.short_name;
          if (side == 2)
            document.getElementsByName('nach_tr_hsno')[0].value = component.short_name;
          break;
        }

        case "country": {
          country = component.short_name;
          if (side == 1)
            document.getElementsByName('von_ad_country')[0].value = component.short_name;
          if (side == 2)
            document.getElementsByName('nach_ad_country')[0].value = component.short_name;
          break;
        }
  
        case "postal_code": {
          if (!postal_code_dirty) {
            postal_code = component.short_name;
            if (side == 1)
              document.getElementsByName('von_ad_zipcode')[0].value = component.short_name;
            if (side == 2)
              document.getElementsByName('nach_ad_zipcode')[0].value = component.short_name;
          }
          break;
        }
        
        // Bei unvollständigen Eingaben (Straße ohne Hausnummer) wird manchmal nur die ersten beiden Ziffern der PLZ zurückgegeben, erkennbar an "postal_code_prefix"
        case "postal_code_prefix": {
          if (country == "DE") {
            postal_code_dirty = true;
            postal_code = "";
            if (side == 1)
              document.getElementsByName('von_ad_zipcode')[0].value = "";
            if (side == 2)
              document.getElementsByName('nach_ad_zipcode')[0].value = "";
          }
          break;
        }
          
        case "locality": {
          locality = component.long_name;
          if (side == 1)
            document.getElementsByName('von_ad_city')[0].value = component.short_name;
          if (side == 2)
            document.getElementsByName('nach_ad_city')[0].value = component.short_name;
          break;
        }
      }
    }
  }

  // After filling the form with address components from the Autocomplete
  // prediction, set cursor focus on the second address line to encourage
  // entry of subpremise information such as apartment, unit, or floor number.
  parent.frames[2].saveFormFields();
  if (side == 1)
    document.getElementsByName('von_tr_remark')[0].focus();
  if (side == 2)
    document.getElementsByName('nach_tr_remark')[0].focus();

  if (accuracy > 6) {
    ajaxRequestGetAsync('../include/ajaxReqKmPrice.php', "mode=coords&a=" + route + ";" + street_number + ";" + postal_code + ";" + locality + ";" + country + ";" + lat + ";" + lng + ";" + accuracy);
  }
}
self.setTimeout('initAutocomplete1(0)', 100);
</script><noscript>
<center>
<b><br>JavaScript ist nicht verf&uuml;gbar. Bitte aktivieren Sie JavaScript<br><br>
in Ihrem Browser, damit diese Seite ordnungsgem&auml;&szlig; funktioniert!</b><br><br>
</center>
</noscript>
</head>
<body>
<table border=0 width=100% align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<form name="tourNoForm" action="dummy.htm">
<tr>
<td width=2%>
&nbsp;
</td>
<td width=7% align=center>
<img name="start_gif" src="../images/start.gif" height=25 border=0 alt="Start">
</td>
<td width=7% align=right valign=bottom>
&nbsp;
</td>
<td width=29% align=right valign=bottom colspan=2>
<input name="von_csc_name" type="text" value="" size="57" maxlength="57" class="hideSmall" readonly>
</td>
<td width=10% align=center valign=bottom>
<div class=headline2a>
Etappe&nbsp;<input name="tourNoVal" type="text" value="1"
size="<?php echo $_TOURNOVALSIZE_;?>" maxlength="<?php echo $_TOURNOVALSIZE_;?>" class="hideBiga" readonly>
</div>
</td>
<td width=29% align=left valign=bottom colspan=2>
<input name="nach_csc_name" type="text" value="" size="57" maxlength="57" class="hideSmall" readonly>
</td>
<td width=7% align=right valign=bottom>
&nbsp;
</td>
<td width=7% align=center>
<img name="goal_gif" src="../images/goal.gif" height=25 border=0 alt="Ziel">
</td>
<td width=2%>
&nbsp;
</td>
</tr>
</form>
<tr>
<form name="tourForm" action="dummy.htm">
<td>
&nbsp;
</td>
<td colspan=4 align=right>
<input type="button" name="vonFirmaButton" value="..."
class="button_enabled"
tabindex="<?php echo $_vonFirmaButton_tabindex_;?>" title="Suchen: von Firma (alt+<?php echo $_vonFirmaButton_accesskey_;?>)" accesskey="<?php echo $_vonFirmaButton_accesskey_;?>" onclick="parent.frames[2].searchCsCsc(0)">
<input name="von_cs_comp" type="text" value="" size="21" maxlength="50" class="input"
tabindex="<?php echo $_von_cs_comp_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<input name="von_tr_person" type="text" value="" size="20" maxlength="50" class="input"
tabindex="<?php echo $_von_tr_person_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<select name="select_von_tr_person" class="input" style="width:20px;display:none" tabindex="" onchange="parent.frames[2].set_tr_person(0)">
</select>
<input type="hidden" name="von_csc_id" value="">
</td>
<td align=center>
Firma, Person
</td>
<td colspan=2 align=left>
<input name="nach_cs_comp" type="text" value="" size="21" maxlength="50" class="input"
tabindex="<?php echo $_nach_cs_comp_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<input name="nach_tr_person" type="text" value="" size="20" maxlength="50" class="input"
tabindex="<?php echo $_nach_tr_person_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<select name="select_nach_tr_person" class="input" style="width:20px;display:none" tabindex="" onchange="parent.frames[2].set_tr_person(1)">
</select>
<input type="button" name="nachFirmaButton" value="..."
class="button_enabled"
tabindex="<?php echo $_nachFirmaButton_tabindex_;?>" title="Suchen: nach Firma (alt+<?php echo $_nachFirmaButton_accesskey_;?>)" accesskey="<?php echo $_nachFirmaButton_accesskey_;?>" onclick="parent.frames[2].searchCsCsc(1)">
<input type="hidden" name="nach_csc_id" value="">
</td>
<td rowspan=5 colspan=2 align=left valign=top>
Auftragseingang&nbsp;per<br>
<table border=0 align=left cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<tr>
<td align=left width=50%>
<!--
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br>
Auftragseingang&nbsp;per&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
-->
<input type="radio" name="jb_origin" value="1" tabindex="<?php echo $_origin1_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang per Telefon"
<?php if (isset($jb_origin) && $jb_origin == "1") echo " checked"; ?>>
<b>Telefon</b><br>
</td>
<td align=left>
<input type="radio" name="jb_origin" value="5" tabindex="<?php echo $_origin5_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang per Dauerauftrag"
<?php if (isset($jb_origin) && $jb_origin == "5") echo " checked"; ?> disabled>
<b>Dauerauftrag</b><br>
</td>
</tr>
<tr>
<td align=left>
<input type="radio" name="jb_origin" value="2" tabindex="<?php echo $_origin2_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang per Mail"
<?php if (isset($jb_origin) && $jb_origin == "2") echo " checked"; ?>>
<b>Mail</b><br>
</td>
<td align=left>
<input type="radio" name="jb_origin" value="7" tabindex="<?php echo $_origin7_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang per Listenbuchung"
<?php if (isset($jb_origin) && $jb_origin == "7") echo " checked"; ?>disabled>
<b>Listenbuchung</b><br>
</td>
</tr>
<tr>
<td align=left>
<input type="radio" name="jb_origin" value="3" tabindex="<?php echo $_origin3_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang per Schnittstelle"
<?php if (isset($jb_origin) && $jb_origin == "3") echo " checked"; ?> disabled>
<b>Schnittstelle</b><br>
</td>
<td align=left>
<input type="radio" name="jb_origin" value="8" tabindex="<?php echo $_origin8_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang per Höherversicherung"
<?php if (isset($jb_origin) && $jb_origin == "8") echo " checked"; ?> disabled>
<b>Höherversicherung</b><br>
</td>
</tr>
<tr>
<td align=left>
<input type="radio" name="jb_origin" value="4" tabindex="<?php echo $_origin4_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang per KAE"
<?php if (isset($jb_origin) && $jb_origin == "4") echo " checked"; ?> disabled>
<b>KAE</b><br>
</td>
<td align=left>
<input type="radio" name="jb_origin" value="6" tabindex="<?php echo $_origin6_tabindex_;?>"
onclick="parent.frames[2].checkOrigin()" title="Auftragseingang sonstiges"
<?php if (isset($jb_origin) && $jb_origin == "6") echo " checked"; ?>>
<b>Sonstiges</b><br>
</td>
</tr>
<tr>
<td align=left colspan=2>
<div id="div_jb_origin_other" style="display:none">
<input name="jb_origin_other" type="text" size="20" maxlength="40"
class="inputRed" tabindex="<?php echo $_origin6_tabindex_;?>" onchange="parent.frames[2].checkOrigin()" value="<?php echo (isset($jb_origin_other) ? $jb_origin_other : "");?>">
</div>
<br>
Besteller:&nbsp;&nbsp;&nbsp;&nbsp;
<input name="jb_orderer" type="text" size="20" maxlength="50" class="input" tabindex="<?php echo $_jb_orderer_tabindex_;?>" onchange="parent.frames[2].check_jb_orderer()">
<br>
Rg.-Ko.-Nr.:
<input name="jb_commission_no" type="text" size="20" maxlength="50" class="input" tabindex="<?php echo $_jb_commission_no_tabindex_;?>" title="Erscheint als Kommission auf der Rechnung"  onchange="parent.frames[2].check_jb_commission_no()">
<div id="div_jb_offer_mail" style="display: none; margin:0; padding:0; border: 0px solid green;">
<br>
Abgebotsmail senden an:
<input name="jb_offer_mail" type="text" size="27" class="input" tabindex="<?php echo $_jb_offer_mail_tabindex_;?>" onchange="parent.frames[2].saveEmailAddressOffer()">
</div>
</td>
</tr>
</table>
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td colspan=4 align=right>
<input type="button" name="vonAdressButton" value="..."
class="button_enabled"
tabindex="<?php echo $_vonAdressButton_tabindex_;?>" title="Suchen: von Adresse (alt+<?php echo $_vonAdressButton_accesskey_;?>)" accesskey="<?php echo $_vonAdressButton_accesskey_;?>" onclick="parent.frames[2].searchAddress(0);">
<input name="von_ad_street" id="von_autocomplete" type="text" value="" size="38" maxlength="50" class="input"
tabindex="<?php echo $_von_ad_street_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<input name="von_tr_hsno" type="text" value="" size="3" maxlength="10" class="input"
tabindex="<?php echo $_von_tr_hsno_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
</td>
<td align=center>
Stra&szlig;e, Nr.
</td>
<td colspan=2 align=left>
<input name="nach_ad_street" id="nach_autocomplete" type="text" value="" size="38" maxlength="50" class="input"
tabindex="<?php echo $_nach_ad_street_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<input name="nach_tr_hsno" type="text" value="" size="3" maxlength="10" class="input"
tabindex="<?php echo $_nach_tr_hsno_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<input type="button" name="nachAdressButton" value="..."
class="button_enabled"
tabindex="<?php echo $_nachAdressButton_tabindex_;?>" title="Suchen: nach Adresse (alt+<?php echo $_nachAdressButton_accesskey_;?>)" accesskey="<?php echo $_nachAdressButton_accesskey_;?>" onclick="parent.frames[2].searchAddress(1);">
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td colspan=4 align=right>
<?php echo $CUSTOMER_DISABLED_START;?>
<input type="button" name="von_tr_mediationarea_id_Button" value="Rg.-Plz"
class="button_enabled"
tabindex="<?php echo $_von_tr_mediationarea_id_Button_tabindex_;?>" title="Abrechnungs-PLZ eingeben" onclick="parent.frames[2].mk_tr_mediationarea_id(0)">
<input type="hidden" name="von_tr_mediationarea_id">
<?php echo $CUSTOMER_DISABLED_END;?>
<select class="input" name="von_ad_country" tabindex="<?php echo $_von_ad_country_tabindex_;?>"
onchange="parent.frames[2].saveFormFields()">
<?php echo addOptionsFromTable("phoenix_special.country","cou_iso_2","cou_iso_2","cou_iso_2","cou_continent = '1'","DE"); ?>
</select>
<input name="von_ad_zipcode" type="text" value="" size="7" maxlength="10" class="input"
tabindex="<?php echo $_von_ad_zipcode_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<input name="von_ad_city" type="text" value="" size="26" maxlength="50" class="input"
tabindex="<?php echo $_von_ad_city_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
</td>
<td align=center>
PLZ, Ort
</td>
<td colspan=2 align=left>
<select class="input" name="nach_ad_country" tabindex="<?php echo $_nach_ad_country_tabindex_;?>"
onchange="parent.frames[2].saveFormFields()">
<?php echo addOptionsFromTable("phoenix_special.country","cou_iso_2","cou_iso_2","cou_iso_2","cou_continent = '1'","DE"); ?>
</select>
<input name="nach_ad_zipcode" type="text" value="" size="7" maxlength="10" class="input"
tabindex="<?php echo $_nach_ad_zipcode_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<input name="nach_ad_city" type="text" value="" size="26" maxlength="50" class="input"
tabindex="<?php echo $_nach_ad_city_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
<?php echo $CUSTOMER_DISABLED_START;?>
<input type="button" name="nach_tr_mediationarea_id_Button" value="Rg.-Plz"
class="button_enabled"
tabindex="<?php echo $_nach_tr_mediationarea_id_Button_tabindex_;?>" title="Abrechnungs-PLZ eingeben" onclick="parent.frames[2].mk_tr_mediationarea_id(1)">
<input type="hidden" name="nach_tr_mediationarea_id">
<?php echo $CUSTOMER_DISABLED_END;?>
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td colspan=5 align=right>
<input type="button" name="_von_tr_remark_Button" value="..."
class="button_enabled"
tabindex="<?php echo $_von_tr_remark_Button_tabindex_;?>" title="Bemerkung (alt+<?php echo $_von_tr_remark_Button_accesskey_;?>)" accesskey="<?php echo $_von_tr_remark_Button_accesskey_;?>" onclick="parent.frames[2].mk_tr_remark_Text(0)">
<input type="checkbox" name="hide_von_tr_remark" value="1"
tabindex="<?php echo $_hide_von_tr_remark_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">
<textarea name="von_tr_remark" class="input" tabindex="<?php echo $_von_tr_remark_tabindex_;?>" cols="43" rows="3"
onchange="parent.frames[2].saveFormFields()"></textarea>
</td>
<td align=center>
Bemerkung
</td>
<td colspan=2 align=left>
<textarea name="nach_tr_remark" class="input" tabindex="<?php echo $_nach_tr_remark_tabindex_;?>"
cols="43" rows="3" onchange="parent.frames[2].saveFormFields()"></textarea>
<input type="checkbox" name="hide_nach_tr_remark" value="1"
tabindex="<?php echo $_hide_nach_tr_remark_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">
<input type="button" name="_nach_tr_remark_Button" value="..."
class="button_enabled"
tabindex="<?php echo $_nach_tr_remark_Button_tabindex_;?>" title="Bemerkung (alt+<?php echo $_nach_tr_remark_Button_accesskey_;?>)" accesskey="<?php echo $_nach_tr_remark_Button_accesskey_;?>" onclick="parent.frames[2].mk_tr_remark_Text(1)">
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td colspan=5 align=right>
<input name="von_tr_commission_no" type="text" size="30" maxlength="30" class="input" tabindex="<?php echo $_von_tr_commission_no_tabindex_;?>" title="Erscheint im Rechnungstext" onchange="parent.frames[2].saveFormFields()">
</td>
<td align=center>
Ko.-Nr.
</td>
<td colspan=2 align=left>
<input name="nach_tr_commission_no" type="text" size="30" maxlength="30" class="input" tabindex="<?php echo $_nach_tr_commission_no_tabindex_;?>" title="Erscheint im Rechnungstext" onchange="parent.frames[2].saveFormFields()">
</td>
<td>
&nbsp;
</td>
</tr>
<tr id="tr_tracking_row" style="visibility:collapse">
<td colspan=5 align=right id="tr_tracking_von" style="visibility:collapse">
<input name="von_tr_tracking" type="text" size="43" maxlength="60" class="input" tabindex="<?php echo $_von_tr_tracking_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
</td>
<td align=center>
Tracking-eMail
</td>
<td colspan=5 align=left id="tr_tracking_nach" style="visibility:collapse">
<input name="nach_tr_tracking" type="text" size="43" maxlength="60" class="input" tabindex="<?php echo $_nach_tr_tracking_tabindex_;?>" onchange="parent.frames[2].saveFormFields()">
</td>
</tr>
<tr>
<td>
<span class="verysmall">&nbsp;</span>
</td>
<td align=center>
<button name="prevButton" type="button" value="zur&uuml;ck" style="height: 20px;"
class="button_disabled"
tabindex="<?php echo $_prevButton_tabindex_;?>" onClick="parent.frames[2].prevTour()" title="zur&uuml;ck (alt+<?php echo $_prevButton_accesskey_;?>)" accesskey="<?php echo $_prevButton_accesskey_;?>" disabled>
<img name="prev_gif" src="../images/prev_dis.gif" height="10" width="26" border="0">
</button>
</td>
<td align=center>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name="waste1Button" type="button" value="l&ouml;schen"  style="height: 20px;"
class="button_enabled"
tabindex="<?php echo $_waste1Button_tabindex_;?>" onClick="parent.frames[2].delTour(0)" title="links l&ouml;schen (alt+<?php echo $_waste1Button_accesskey_;?>)" accesskey="<?php echo $_waste1Button_accesskey_;?>">
<img name="waste_left_gif" src="../images/waste.png" border=0 height=16 width=16>
</button>
&nbsp;&nbsp;
</td>
<td align=right colspan=2>
<?php echo $PHOTO_DISABLED_START;?>
<input type="checkbox" name="tr_photo_von" value="1"
tabindex="<?php echo $_tr_photo_von_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">&nbsp;<span id="span_photo_von">Pflichtfoto</span>&nbsp;&nbsp;
<?php echo $PHOTO_DISABLED_END;?>
<input type="checkbox" name="tr_ware_from_von" value="1"
tabindex="<?php echo $_tr_ware_from_von_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">An&nbsp;
<input type="checkbox" name="tr_ware_to_von" value="1"
tabindex="<?php echo $_tr_ware_to_von_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">Ab
</td>
<td align=center>
<span class="verysmall"><br></span>
<button name="switchButton" type="button" value="vertauschen" style="height: 20px;"
class="button_enabled"
tabindex="<?php echo $_switchButton_tabindex_;?>" onClick="parent.frames[2].switchJobList()" title="vertauschen (alt+<?php echo $_switchButton_accesskey_;?>)" accesskey="<?php echo $_switchButton_accesskey_;?>">
<img name="switch_gif" src="../images/switch.gif" height="10" width="26" border="0">
</button>
</td>
<td align=left colspan=2>
<input type="checkbox" name="tr_ware_from_nach" value="1"
tabindex="<?php echo $_tr_ware_from_nach_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">An
<input type="checkbox" name="tr_ware_to_nach" value="1"
tabindex="<?php echo $_tr_ware_to_nach_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">Ab
&nbsp;&nbsp;
<?php echo $PHOTO_DISABLED_START;?>
&nbsp;<input type="checkbox" name="tr_photo_nach" value="1"
tabindex="<?php echo $_tr_photo_nach_tabindex_;?>" onclick="parent.frames[2].saveFormFields()">&nbsp;<span id="span_photo_nach">Pflichtfoto</span>
<?php echo $PHOTO_DISABLED_END;?>
</td>
<td align=center>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name="waste2Button" type="button" value="l&ouml;schen" style="height: 20px;"
class="button_enabled"
tabindex="<?php echo $_waste2Button_tabindex_;?>" onClick="parent.frames[2].delTour(1)" title="rechts l&ouml;schen (alt+<?php echo $_waste2Button_accesskey_;?>)" accesskey="<?php echo $_waste2Button_accesskey_;?>">
<img name="waste_right_gif" src="../images/waste.png" border=0 height=16 width=16>
</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td align=center>
<button name="nextButton" type="button" value="vor" style="height: 20px;"
class="button_enabled"
tabindex="<?php echo $_nextButton_tabindex_;?>" onClick="parent.frames[2].nextTour()" title="vor (alt+<?php echo $_nextButton_accesskey_;?>)" accesskey="<?php echo $_nextButton_accesskey_;?>">
<img name="next_gif" src="../images/next.gif" height=10 width=26 border=0>
</button>
</td>
<td>
<span class="verysmall">&nbsp;</span>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td colspan=9>
&nbsp;
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td height=10>
&nbsp;
</td>
<td align=left valign=top colspan=3>
<table border=0 width=100% align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<tr>
<td height=40>
<input type="checkbox" name="accept_all_addresses" value="1" tabindex="<?php echo $_accept_all_addresses_tabindex_;?>"
onclick="parent.frames[2].checkAccept_all_addresses()" title="Adressen&nbsp;ungepr&uuml;ft&nbsp;&uuml;bernehmen (alt+<?php echo $_accept_all_addresses_accesskey_;?>)"
accesskey="<?php echo $_accept_all_addresses_accesskey_;?>">&nbsp;
Adressen&nbsp;ungepr&uuml;ft&nbsp;&uuml;bernehmen
</td>
<td align=right>
<div id="div_jb_cashpayer_mail" style="display: none; margin:0; padding:0; border: 0px solid green;">
<?php echo $JB_CASHPAYER_MAIL_DISABLED_START;?>
<?php echo $cs_jbstatusmailstr;?>&nbsp;an:&nbsp;
<input name="jb_cashpayer_mail" type="text" size="27" class="input" tabindex="<?php echo $_jb_cashpayer_mail_tabindex_;?>" onchange="parent.frames[2].saveEmailAddress()">
<?php echo $JB_CASHPAYER_MAIL_DISABLED_END;?>
</div>
</td>
</tr>
<tr>
<td colspan=2>
<input type="button" name="searchOldJobButton" value="Suche Job(s)"
class="button_enabled"
tabindex="<?php echo $_searchOldJobButton_tabindex_;?>" title="Suchen: nach Jobs" onclick="parent.frames[2].searchJbList()">
&nbsp;
<input type="button" name="duplicateJobButton" value="Kopieren"
class="button_disabled"
tabindex="<?php echo $_duplicateJobButton_tabindex_;?>" title="Auftrag kopieren (alt+<?php echo $_duplicateJobButton_accesskey_;?>)" accesskey="<?php echo $_duplicateJobButton_accesskey_;?>" onclick="parent.frames[2].duplicateJob()" disabled>
<?php echo $EMP_MODE_LATERJOB_START;?>
&nbsp;
<input type="button" name="getLastJobButton" value="Letzter Auftrag"
class="button_enabled"
tabindex="<?php echo $_duplicateJobButton_tabindex_;?>" title="Letzten Auftrag kopieren" onclick="parent.frames[2].getLastJob()">
<?php echo $EMP_MODE_LATERJOB_END;?>
<div id="div_optimize" style="float:right;display:none">
<input type="button" name="OptimizeButton" value="Optimieren"
class="button_enabled"
 title="Optimieren" accesskey="" onclick="javascript:parent.frames[2].openDistanceprice('optimize');">
<input type="checkbox" name="dont_optimize_last" value="1" tabindex="" title="Endstation bleibt bei der Optimierung bestehen" checked
accesskey="<?php echo $_accept_all_addresses_accesskey_;?>">&nbsp;au&szlig;er Endstation
</div>
</td>
</tr>
</table>
</td>
<td colspan=3 valign=top>
<table border=0 width=100% align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<tr>
<td align=right width=35%>
<?php echo $CUSTOMER_DISABLED_START;?>
<input type="radio" name="payer_from" value="von" class="input"
tabindex="<?php echo $_payer_from_tabindex_;?>" onclick="parent.frames[2].checkPayer(0)">
<?php echo $CUSTOMER_DISABLED_END;?>
</td>
<td align=center width=30%>
<?php echo $CUSTOMER_DISABLED_START;?>
<?php echo $PAYER_TEXT;?>
<?php echo $CUSTOMER_DISABLED_END;?>
</td>
<td align=left width=35%>
<?php echo $CUSTOMER_DISABLED_START;?>
<input type="radio" name="payer_to" value="nach" class="input"
tabindex="<?php echo $_payer_to_tabindex_;?>" onclick="parent.frames[2].checkPayer(1)">
<?php echo $CUSTOMER_DISABLED_END;?>
</td>
</tr>
<tr>
<td colspan=3 align=center><br>
<?php echo $CUSTOMER_DISABLED_START;?>
<input type="radio" name="jb_cash" value="1"
tabindex="<?php echo $_jb_cash_tabindex_;?>" title="Barzahlung (alt+<?php echo $_jb_cash_accesskey_;?>)" accesskey="<?php echo $_jb_cash_accesskey_;?>" onclick="parent.frames[2].checkCash(true)">
Barzahlung
<input type="radio" name="jb_costsplit" value="1"
tabindex="<?php echo $_jb_costsplit_tabindex_;?>" title="<?php echo $COSTSPLIT_TITLE;?> (alt+<?php echo $_jb_costsplit_accesskey_;?>)" accesskey="<?php echo $_jb_costsplit_accesskey_;?>" onclick="parent.frames[2].checkCostsplit(true)">
<?php echo $COSTSPLIT_TEXT;?>&nbsp;
<?php echo $CUSTOMER_DISABLED_END;?>
<input type="button" name="jb_freetextButton" value="Text"
class="button_enabled"
tabindex="<?php echo $_jb_freetextButton_tabindex_;?>" title="Rechnungstext (alt+<?php echo $_jb_freetextButton_accesskey_;?>)" accesskey="<?php echo $_jb_freetextButton_accesskey_;?>" onclick="parent.frames[2].mkRechnungsText('normal')">
&nbsp;&nbsp;&nbsp;
<div id="div_jb_hiddenFreetextButton" style="display:none">
<input type="button" name="jb_hiddenFreetextButton" value="Text nur Rg"
class="button_enabled"
tabindex="<?php echo $_jb_hiddenFreetextButton_tabindex_;?>" title="Rechnungstext nur für den Rechnungsempfänger" onclick="parent.frames[2].mkRechnungsText('hidden')">
&nbsp;&nbsp;&nbsp;
</div>
<?php echo $MASK_CUSTOMER_PRICEQUERY_DISABLED_START;?>
<input type="button" name="jb_priceQueryButton" value="Preisanfrage"
class="button_enabled"
tabindex="" title="Rechnungstext (alt+)" accesskey="" onclick="parent.frames[2].mkPriceQuery()">
&nbsp;&nbsp;&nbsp;
<?php echo $MASK_CUSTOMER_PRICEQUERY_DISABLED_END;?>
<?php echo $CUSTOMER_DISABLED_START;?>
<input type="button" name="jb_dispoInfoButton" value="Dispo Info"
class="button_enabled"
tabindex="" title="Dispo Info" accesskey="" onclick="parent.frames[2].mkDispoInfo()">
&nbsp;&nbsp;&nbsp;
<?php echo $CUSTOMER_DISABLED_END;?>
</td>
</tr>
</table>
</td>
<td align=left valign=top colspan=3>
<table border = 1 align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<tr><td valign=center>
<table border=0 width=100% align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<tr><td valign=center align=left>
&nbsp;Standardpreis:
</td><td valign=center align=right>
&nbsp;<input name="currentPrice" type="text" value="" size="23" maxlength="23" class="hideRed" readonly>
</td></tr>
<?php echo (MASK_CR_PRICE_MODE == "1" ? "" : "<!--");?>
<tr><td valign=center align=left>
&nbsp;Standard-Frachtverg.:
</td><td valign=center align=right>
&nbsp;<input name="currentCrPrice" type="text" value="" size="23" maxlength="23" class="hideRed" readonly>
</td></tr>
<?php echo (MASK_CR_PRICE_MODE == "1" ? "" : "-->");?>
<tr><td valign=top align=left>
&nbsp;<i><a href="javascript:parent.frames[2].openDistanceprice();">Kilometerpreis:</a></i><br>
</td><td valign=center align=left>
<div id="div_distanceprice"></div>
</td></tr>
<tr id="tr_zoneprice" style="visibility:collapse"><td valign=top align=left>
&nbsp;<i><a href="javascript:parent.frames[2].openDistanceprice('zone');">PZM-Preis:</a></i><br>
</td><td valign=center align=left>
<div id="div_zoneprice"></div>
</td></tr>
</table>
</td>
</tr>
<tr><td>
<table border=0 width=100% align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<tr><td valign=center align=left>
&nbsp;Rechnung an:<br>
<div id="maskDisplayBerichteButton" name="maskDisplayBerichteButton" style="float:left">
<input type="button" name="BerichteButton" value="[B]"
class="button_enabled"
tabindex="<?php echo $_Berichte_tabindex_;?>" title="Berichte" accesskey="" onclick="parent.frames[2].getReports()">
</div>
<div id="maskDisplayDokumenteButton" name="maskDisplayDokumenteButton" style="float:left">
<input type="button" name="DokumenteButton" value="[D]"
class="button_enabled"
tabindex="<?php echo $_Dokumente_tabindex_;?>" title="Dokumente" accesskey="" onclick="parent.frames[2].getDocuments()">
</div>
<input name="nameOfPayer" type="text" value="" size="25" maxlength="25" class="hideRed" readonly>
<?php echo $CUSTOMER_DISABLED_START;?>
<input type="button" name="bezahlerFirmaButton" value="..."
class="button_enabled"
tabindex="<?php echo $_bezahlerFirmaButton_tabindex_;?>" title="Suchen: Drittzahler (alt+<?php echo $_bezahlerFirmaButton_accesskey_;?>)" accesskey="<?php echo $_bezahlerFirmaButton_accesskey_;?>" onclick="parent.frames[2].searchCsCsc(2)">
<?php echo $CUSTOMER_DISABLED_END;?>
</td></tr>
<tr><td valign=bottom align=left>
&nbsp;Rechnungs-Email:
<img name="info_svg" src="../images/Info_i_yellow.svg" height=12 border=0 alt="info" title="Gemäß Wachstumschancengesetz vom 27.3.2024 (BGBl 2024 I Nr. 108) sind wir zum digitalen Rechnungsversand im B2B - Bereich verpflichtet.">
<br>
<input name="invmailOfPayer" type="text" value="" size="25" maxlength="200" class="hideRed" onchange="parent.frames[2].saveInvmail()" readonly>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td height=10>
&nbsp;
</td>
</form>
</tr>
<tr>
<td>
&nbsp;
</td>
<td colspan=9>
<table border=0 width=100% align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>
<td align=center valign=top>
<div id="von_cmp_remark_div" style="width: 50em; border-style:none;">&nbsp;</div>
</td>
<td align=center valign=top>
<div id="dritt_cmp_remark_div" style="width: 50em; border-style:none;">&nbsp;</div>
</td>
<td align=center valign=top>
<div id="nach_cmp_remark_div" style="width: 50em; border-style:none;">&nbsp;</div>
</td>
</table>
</td>
&nbsp;
<td>
</td>
</tr>
</table>
    <div class="buttons">
        <button class="btn btn-upload" onclick="openCombinedModal(true)" title="Dateien verwalten">
            <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
                <polyline points="17 8 12 3 7 8"></polyline>
                <line x1="12" y1="3" x2="12" y2="15"></line>
            </svg>
        </button>
    </div>
    <button class="btn" onclick="openGeocords()" title="Standort wählen">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
        <path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"/>
        <circle cx="12" cy="9" r="2.5"/>
      </svg>
    </button>

    <div id="result">Noch kein Standort gewählt.</div>

    <!-- Overlay -->
    <div id="geocords-overlay" onclick="closeOverlay(event)">
      <iframe id="geocords-iframe" allow="storage-access"></iframe>
    </div>

    <div class="buttons">
        <button class="btn btn-upload" onclick="openCombinedModal(false)" title="Dateien verwalten">
            <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
                <polyline points="17 8 12 3 7 8"></polyline>
                <line x1="12" y1="3" x2="12" y2="15"></line>
            </svg>
        </button>
    </div>
</body>
</html>
<script>
      var UPLOAD_SERVER = 'https://uplman.assecutor.net';
      var formular_id = 12345;

      function openCombinedModal(readonly) {
          var existing = document.getElementById('upload-overlay');
          if (existing) existing.remove();

          var overlay = document.createElement('div');
          overlay.id = 'upload-overlay';
          overlay.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.5);backdrop-filter:blur(4px);z-index:9999;display:flex;justify-content:center;align-items:center;';
          overlay.innerHTML = '<iframe src="' + UPLOAD_SERVER + '/upload?ref=' + formular_id + '&readonly='+ readonly +'" allow="storage-access" style="width:90vw;max-width:780px;height:85vh;border:none;border-radius:16px;box-shadow:0 20px 60px rgba(0,0,0,0.3);"></iframe>';
          overlay.addEventListener('click', function(e) { if (e.target === overlay) overlay.remove(); });
          document.body.appendChild(overlay);
      }

      // Events empfangen
      window.addEventListener('message', function(event) {
          var data = event.data;
          if (!data || !data.type) return;

          if (data.type === 'upload-success') {
              console.log('Upload erfolgreich:', data);
              saveToMyDatabase({
                  upload_id: data.sessionId,
                  upload_type: 'job',
                  reference_id: data.sessionId,
                  filename: data.file.filename,
                  remark: data.file.remark || '',
                  view_url: data.file.viewUrl,
                  download_url: data.file.downloadUrl,
                  size_bytes: data.file.sizeBytes,
                  counter: 0
              });
          }

          if (data.type === 'delete-success') {
              console.log('Loeschung erfolgreich:', data);
              deleteFromMyDatabase({
                  deleted: 'file',
                  upload_id: data.sessionId,
                  upload_type: 'job',
                  reference_id: data.sessionId,
                  filename: data.file.filename,
                  remark: data.file.remark || '',
                  view_url: data.file.viewUrl || ''
              });
          }
      });

      function saveToMyDatabase(fileData) {
          console.log("gdc insert");
          fetch('save-file-upload.php', {
              method: 'POST',
              headers: { 'Content-Type': 'application/json' },
              body: JSON.stringify(fileData)
          })
          .then(function(response) { return response.json(); })
          .then(function(result) { console.log('Gespeichert:', result); })
          .catch(function(error) { console.error('Fehler:', error); });
      }

      function deleteFromMyDatabase(deleteData) {
          console.log("gdc delete");
          fetch('delete-file-upload.php', {
              method: 'POST',
              headers: { 'Content-Type': 'application/json' },
              body: JSON.stringify(deleteData)
          })
          .then(function(response) { return response.json(); })
          .then(function(result) { console.log('Geloescht:', result); })
          .catch(function(error) { console.error('Fehler beim Loeschen:', error); });
      }

      // ESC zum Schliessen
      document.addEventListener('keydown', function(e) {
          if (e.key === 'Escape') {
              var ul = document.getElementById('upload-overlay');
              if (ul) ul.remove();
          }
      });

        function deleteFromMyDatabase(deleteData) {
          console.log("gdc delete");
            fetch('delete-file-upload.php', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(deleteData)
            })
            .then(function(response) { return response.json(); })
            .then(function(result) {
                console.log('Gelöscht:', result);
            })
            .catch(function(error) {
              // console.log('Delete Response:', JSON.stringify(result, null, 2));
                console.error('Fehler beim Löschen:', error);
            });
        }

        function saveToMyDatabase(fileData) {
          console.log("gdc insert");
            fetch('save-file-upload.php', {  
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(fileData)
            })
            .then(response => response.json())
            .then(result => {
                console.log('Gespeichert:', result);
            })
            .catch(error => {
                console.error('Fehler:', error);
            });
        }

        // ============================================================
        // KONFIGURATION: URL der Geocords-App anpassen!
        // ============================================================
        var GEOCORDS_URL = 'https://geo.assecutor.net';

        // Safari-Erkennung: Safari blockiert Iframes, daher automatisch Popup
        var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

        // Oeffnet Geocords: Iframe (Standard) oder Popup (Safari)
        function openGeocords() {
            if (isSafari) {
                openGeocodsPopup();
                return;
            }
            var iframe = document.getElementById('geocords-iframe');
            iframe.src = GEOCORDS_URL;
            document.getElementById('geocords-overlay').classList.add('active');
        }

        function closeOverlay(e) {
            if (e.target === e.currentTarget) {
                document.getElementById('geocords-overlay').classList.remove('active');
                document.getElementById('geocords-iframe').src = '';
            }
        }

        // Popup-Fenster (keine Cookie-Probleme)
        function openGeocodsPopup() {
            var w = 900, h = 700;
            var left = (screen.width - w) / 2;
            var top = (screen.height - h) / 2;
            window.open(
                GEOCORDS_URL,
                'geocords',
                'width=' + w + ',height=' + h + ',left=' + left + ',top=' + top
            );
        }

        // --- Message-Listener (funktioniert für Iframe UND Popup) ---
        window.addEventListener('message', function(event) {
            var result = document.getElementById('result');

            if (event.data.type === 'geocords-confirmed') {
                result.textContent = 'Bestätigt: ' + event.data.lat + ', ' + event.data.lng;
                result.className = 'has-coords';

                // Iframe schließen
                document.getElementById('geocords-overlay').classList.remove('active');
                document.getElementById('geocords-iframe').src = '';

                // Hier mit den Koordinaten weiterarbeiten:
                console.log('Lat:', event.data.lat, 'Lng:', event.data.lng);
            }

            if (event.data.type === 'geocords-closed') {
                if (event.data.hasMarker) {
                    result.textContent = 'Geschlossen mit: ' + event.data.lat + ', ' + event.data.lng;
                    result.className = 'has-coords';
                }
                document.getElementById('geocords-overlay').classList.remove('active');
                document.getElementById('geocords-iframe').src = '';
            }
        });
</script>

<!-- <script>
    // Upload-Modal einbetten
    const refId = '12345';

    // iFrame erstellen
    const iframe = document.createElement('iframe');
    iframe.src = 'https://uplman.assecutor.net/upload?ref=' + refId;
    iframe.style.cssText = 'width:100%;height:600px;border:none;';

    // Events empfangen
    window.addEventListener('message', (event) => {
        if (event.data.type === 'upload-success') {
            const file = event.data.file;
            console.log('Datei:', file.filename);
            console.log('URL:', file.viewUrl);
            console.log('Short-Link:', file.shortLink);
            console.log('Bemerkung:', file.remark);
            // → In DB schreiben...
        }
        if (event.data.type === 'delete-success') {
            // → Aus DB loeschen...
        }
    });

    //     var UPLOAD_SERVER = 'https://uplman.assecutor.net';
    //     var formular_id = 9999;
    //     var type = 0;
    //     var readOnly = false; // true = nur Ansicht + Download, kein Upload/Löschen

    //     function openCombinedModal() {
    //     // Altes Modal entfernen
    //     var existing = document.querySelector('.um-widget-modal');
    //     if (existing) existing.remove();

    //     var managerUrl = UPLOAD_SERVER + '/manager.php?type=' + type + '&allowDownload=true&ref=' + formular_id
    //         + '&allowDelete=' + (readOnly ? 'false' : 'true');

    //     // Modal erstellen
    //     var modal = document.createElement('div');
    //     modal.className = 'um-widget-modal';

    //     var contentHtml =
    //         '<div class="um-widget-backdrop"></div>' +
    //         '<div class="um-widget-content" style="max-height:90vh;overflow-y:auto;">' +
    //             '<div class="um-widget-header">' +
    //                 '<h3 class="um-widget-title">Dateien verwalten</h3>' +
    //                 '<button type="button" class="um-widget-close" title="Schliessen">' +
    //                     '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">' +
    //                         '<line x1="18" y1="6" x2="6" y2="18"></line>' +
    //                         '<line x1="6" y1="6" x2="18" y2="18"></line>' +
    //                     '</svg>' +
    //                 '</button>' +
    //             '</div>';

    //     // Upload-iframe nur anzeigen wenn nicht readOnly
    //     if (!readOnly) {
    //         var uploadUrl = UPLOAD_SERVER + '/index.php?type=' + type + '&ref=' + formular_id;
    //         contentHtml +=
    //             '<iframe class="um-widget-iframe" src="' + uploadUrl + '" style="height:400px;"></iframe>' +
    //             '<div style="border-top:1px solid #e9ecef;"></div>';
    //     }

    //     contentHtml +=
    //             '<iframe class="um-widget-iframe" id="manager-iframe" src="' + managerUrl + '" style="height:' + (readOnly ? '500' : '350') + 'px;"></iframe>' +
    //         '</div>';

    //     modal.innerHTML = contentHtml;
    //     document.body.appendChild(modal);

    //     // Schliessen per ESC
    //     var escHandler = function(e) {
    //         if (e.key === 'Escape' || e.keyCode === 27) {
    //             modal.remove();
    //             document.removeEventListener('keydown', escHandler);
    //             window.removeEventListener('message', messageHandler);
    //         }
    //     };
    //     document.addEventListener('keydown', escHandler);

    //     // Schliessen per Backdrop-Klick
    //     modal.querySelector('.um-widget-backdrop').addEventListener('click', function() {
    //         modal.remove();
    //         document.removeEventListener('keydown', escHandler);
    //         window.removeEventListener('message', messageHandler);
    //     });

    //     // Schliessen per X-Button
    //     modal.querySelector('.um-widget-close').addEventListener('click', function() {
    //         modal.remove();
    //         document.removeEventListener('keydown', escHandler);
    //         window.removeEventListener('message', messageHandler);
    //     });

    //     // === MESSAGE LISTENER ===
    //     var messageHandler = function(event) {
    //             if (event.origin !== UPLOAD_SERVER) return;
    //             var data = event.data;
    //             if (!data || !data.type) return;

    //             if (data.type === 'upload-success') {
    //                 console.log('Upload erfolgreich:', data.payload);

    //                 // Manager-iframe neu laden (src neu setzen, da cross-origin reload blockiert wird)
    //                 var managerIframe = document.getElementById('manager-iframe');
    //                 if (managerIframe) {
    //                     managerIframe.src = managerUrl;
    //                 }

    //                 // Jede Datei in DB speichern
    //                 var uploadType = data.payload.upload_type;
    //                 var referenceId = data.payload.reference_id;
    //                 var counter = 0;

    //                 data.payload.files.forEach(function(file) {
    //                     saveToMyDatabase({
    //                         upload_id: data.payload.upload_id,
    //                         upload_type: uploadType,
    //                         reference_id: referenceId,
    //                         filename: file.original_filename,
    //                         remark: file.remark,
    //                         view_url: file.view_url,
    //                         download_url: file.download_url,
    //                         size_bytes: file.size_bytes,
    //                         counter: counter
    //                     });
    //                 });
    //             }

    //             if (data.type === 'delete-success') {
    //                 console.log('Löschung erfolgreich:', data.payload);

    //                 if (data.payload.deleted === 'file') {
    //                     // Einzelne Datei gelöscht
    //                     deleteFromMyDatabase({
    //                         deleted: 'file',
    //                         upload_id: data.payload.upload_id,
    //                         upload_type: data.payload.upload_type,
    //                         reference_id: data.payload.reference_id,
    //                         filename: data.payload.filename,
    //                         remark: data.payload.remark || '',
    //                         view_url: data.payload.view_url || ''
    //                     });
    //                 } else if (data.payload.deleted === 'upload') {
    //                     // Ganzer Upload gelöscht - jede Datei einzeln aus DB löschen
    //                     (data.payload.files || []).forEach(function(file) {
    //                         deleteFromMyDatabase({
    //                             deleted: 'file',
    //                             upload_id: data.payload.upload_id,
    //                             upload_type: data.payload.upload_type,
    //                             reference_id: data.payload.reference_id,
    //                             filename: file.filename,
    //                             remark: file.remark || '',
    //                             view_url: file.view_url || ''
    //                         });
    //                     });
    //                 }
    //             }
    //         };
            
    //         window.addEventListener('message', messageHandler);
    // }

    //     function deleteFromMyDatabase(deleteData) {
    //       console.log("gdc delete");
    //         fetch('delete-file-upload.php', {
    //             method: 'POST',
    //             headers: { 'Content-Type': 'application/json' },
    //             body: JSON.stringify(deleteData)
    //         })
    //         .then(function(response) { return response.json(); })
    //         .then(function(result) {
    //             console.log('Gelöscht:', result);
    //         })
    //         .catch(function(error) {
    //           // console.log('Delete Response:', JSON.stringify(result, null, 2));
    //             console.error('Fehler beim Löschen:', error);
    //         });
    //     }

    //     function saveToMyDatabase(fileData) {
    //       console.log("gdc insert");
    //         fetch('save-file-upload.php', {  
    //             method: 'POST',
    //             headers: { 'Content-Type': 'application/json' },
    //             body: JSON.stringify(fileData)
    //         })
    //         .then(response => response.json())
    //         .then(result => {
    //             console.log('Gespeichert:', result);
    //         })
    //         .catch(error => {
    //             console.error('Fehler:', error);
    //         });
    //     }


        // ============================================================
        // KONFIGURATION: URL der Geocords-App anpassen!
        // ============================================================
        var GEOCORDS_URL = 'https://geo.assecutor.net';

        // --- Option 1: Iframe ---
        function openGeocords() {
            var iframe = document.getElementById('geocords-iframe');
            iframe.src = GEOCORDS_URL;
            document.getElementById('geocords-overlay').classList.add('active');
        }

        function closeOverlay(e) {
            if (e.target === e.currentTarget) {
                document.getElementById('geocords-overlay').classList.remove('active');
                document.getElementById('geocords-iframe').src = '';
            }
        }

        // --- Option 2: Popup-Fenster (keine Cookie-Probleme!) ---
        function openGeocodsPopup() {
            var w = 900, h = 700;
            var left = (screen.width - w) / 2;
            var top = (screen.height - h) / 2;
            window.open(
                GEOCORDS_URL,
                'geocords',
                'width=' + w + ',height=' + h + ',left=' + left + ',top=' + top
            );
        }

        // ============================================================
        // KONFIGURATION: URL der Geocords-App anpassen!
        // ============================================================
        var GEOCORDS_URL = 'https://geo.assecutor.net';

        // Safari-Erkennung: Safari blockiert Iframes, daher automatisch Popup
        var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

        // Oeffnet Geocords: Iframe (Standard) oder Popup (Safari)
        function openGeocords() {
            if (isSafari) {
                openGeocodsPopup();
                return;
            }
            var iframe = document.getElementById('geocords-iframe');
            iframe.src = GEOCORDS_URL;
            document.getElementById('geocords-overlay').classList.add('active');
        }

        function closeOverlay(e) {
            if (e.target === e.currentTarget) {
                document.getElementById('geocords-overlay').classList.remove('active');
                document.getElementById('geocords-iframe').src = '';
            }
        }

        // Popup-Fenster (keine Cookie-Probleme)
        function openGeocodsPopup() {
            var w = 900, h = 700;
            var left = (screen.width - w) / 2;
            var top = (screen.height - h) / 2;
            window.open(
                GEOCORDS_URL,
                'geocords',
                'width=' + w + ',height=' + h + ',left=' + left + ',top=' + top
            );
        }

        // --- Message-Listener (funktioniert für Iframe UND Popup) ---
        window.addEventListener('message', function(event) {
            var result = document.getElementById('result');

            if (event.data.type === 'geocords-confirmed') {
                result.textContent = 'Bestätigt: ' + event.data.lat + ', ' + event.data.lng;
                result.className = 'has-coords';

                // Iframe schließen
                document.getElementById('geocords-overlay').classList.remove('active');
                document.getElementById('geocords-iframe').src = '';

                // Hier mit den Koordinaten weiterarbeiten:
                console.log('Lat:', event.data.lat, 'Lng:', event.data.lng);
            }

            if (event.data.type === 'geocords-closed') {
                if (event.data.hasMarker) {
                    result.textContent = 'Geschlossen mit: ' + event.data.lat + ', ' + event.data.lng;
                    result.className = 'has-coords';
                }
                document.getElementById('geocords-overlay').classList.remove('active');
                document.getElementById('geocords-iframe').src = '';
            }
        });

    </script> -->
<script type="text/javascript">
<!--
<?php
    echo "document.getElementById('tr_zoneprice').style.visibility = 'visible';\n";
?>
job_tour_isLoading=false;
-->
</script>
