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

include_once("../include/global.inc.php");
include_once("../include/caglobal.inc.php");
include_once("../include/auth.inc.php");
include_once("../jobs2/job_accesskeys.inc.php");
//if ($phpVersion >= "7.0"):
//  require_once("../PEAR/HTML/Template/IT.php");
//else:
//  require_once("HTML/IT.php");
//endif;

//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'");

//if ($phpVersion >= "7.0"):
//  $tpl = new HTML_Template_IT();
//else:
//  $tpl = new IntegratedTemplate();
//endif;
//$tpl->loadTemplatefile("job_tour.tpl.htm", true, true);
$output = file_get_contents("job_tour.tpl.htm");
//$tpl->setCurrentBlock("touroptions");
//$tpl->setVariable("_von_csc_id_options_", $von_csc_id_options);
$output = str_replace("{_von_csc_id_options_}", $von_csc_id_options, $output);
$output = str_replace("{_nach_csc_id_options_}", $nach_csc_id_options, $output);
if (getParameterValue($emp_id, "MODE_LATER_JOB") == "1"):
  $output = str_replace("{EMP_MODE_LATERJOB_START}", "", $output);
  $output = str_replace("{EMP_MODE_LATERJOB_END}", "", $output);
else:
  $output = str_replace("{EMP_MODE_LATERJOB_START}", "<!--", $output);
  $output = str_replace("{EMP_MODE_LATERJOB_END}", "-->", $output);
endif;

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

if ($csc_id_orderer != '0'):
  // Kundenauftrag
  $output = str_replace("{_is_customer_}", "1", $output);
  $output = str_replace("{CUSTOMER_DISABLED_START}", "<!--", $output);
  $output = str_replace("{CUSTOMER_DISABLED_END}", "-->", $output);
  if (MASK_CUSTOMER_SHOW_PRICEQUERY != "1" || getFieldValueFromId("customer", "cs_id", $cs_id, "cs_invmode") == 0):
    $output = str_replace("{MASK_CUSTOMER_PRICEQUERY_DISABLED_START}", "<!--", $output);
    $output = str_replace("{MASK_CUSTOMER_PRICEQUERY_DISABLED_END}", "-->", $output);
  else:
    $output = str_replace("{MASK_CUSTOMER_PRICEQUERY_DISABLED_START}", "", $output);
    $output = str_replace("{MASK_CUSTOMER_PRICEQUERY_DISABLED_END}", "", $output);
  endif;
  if (MASK_CUSTOMER_SHOW_REMARK != "1"):
    $output = str_replace("{MASK_CUSTOMER_SHOW_REMARK_DISABLED}", "display:none", $output);
  else:
    $output = str_replace("{MASK_CUSTOMER_SHOW_REMARK_DISABLED}", "", $output);
  endif;
  if (getFieldValueFromClause("parameter", "par_value", "par_key='MASK_CUST_SET_PAYER_" . $cs_id . "'") != "1"):
    $output = str_replace("{MASK_CUST_SET_PAYER_DISABLED_START}", "<!--", $output);
    $output = str_replace("{MASK_CUST_SET_PAYER_DISABLED_END}", "-->", $output);
  else:
    $output = str_replace("{MASK_CUST_SET_PAYER_DISABLED_START}", "", $output);
    $output = str_replace("{MASK_CUST_SET_PAYER_DISABLED_END}", "", $output);
  endif;
  if (MASK_CUST_ALL_ADDR_ENABLED != "1"):
    $output = str_replace("{MASK_CUST_ALL_ADDR_DISABLED_START}", "<!--", $output);
    $output = str_replace("{MASK_CUST_ALL_ADDR_DISABLED_END}", "-->", $output);
  else:
    $output = str_replace("{MASK_CUST_ALL_ADDR_DISABLED_START}", "<!--", $output);
    $output = str_replace("{MASK_CUST_ALL_ADDR_DISABLED_END}", "-->", $output);
  endif;
  if (getFieldValueFromClause("parameter", "par_value", "par_key='MASK_CUST_AD_COUNTRY_DISABLED_" . $cs_id . "'") == "1"):
    $output = str_replace("{_ad_country_disabled_}", "disabled", $output);
  else:
    $output = str_replace("{_ad_country_disabled_}", "", $output);
  endif;
  if (getFieldValueFromClause("parameter", "par_value", "par_key='MASK_CS_DONT_SHOW_STANDARD_PRICE_" . $usr_id . "'") == "1" || getParameterValue("0", "CUSTOMER_MASK_CALCULATOR_USAGE_ONLY_" . $cs_id, "0") == "1"):
    $output = str_replace("{_currentPrice_hidden_}", "style=\"visibility:hidden;\"", $output);
    $output = str_replace("{STANDARD_PRICE_HIDDEN_START}", "<!--", $output);
    $output = str_replace("{STANDARD_PRICE_HIDDEN_END}", "-->", $output);
  else:
    $output = str_replace("{_currentPrice_hidden_}", "", $output);
    $output = str_replace("{STANDARD_PRICE_HIDDEN_START}", "", $output);
    $output = str_replace("{STANDARD_PRICE_HIDDEN_END}", "", $output);
  endif;
else:
  $output = str_replace("{_is_customer_}", "0", $output);
endif;

$JB_DISPOINFO_ENABLED_CS_IDS = $db->getOne("SELECT par_text FROM parameter WHERE hq_id = " . $hq_id . " AND par_key = 'JB_DISPOINFO_ENABLED_CS_IDS'", $output);
if (!in_array ($cs_id, explode(",", $JB_DISPOINFO_ENABLED_CS_IDS))):
  $output = str_replace("{JB_DISPOINFO_DISABLED_START}", "<!--", $output);
  $output = str_replace("{JB_DISPOINFO_DISABLED_END}", "-->", $output);
else:
  $output = str_replace("{JB_DISPOINFO_DISABLED_START}", "", $output);
  $output = str_replace("{JB_DISPOINFO_DISABLED_END}", "", $output);
endif;

if ($db->getOne("SELECT cs_id from customer WHERE cs_id_parent = " . $cs_id) == "") {
  $output = str_replace("{THIRDPAYER_DISABLED_START}", "<!--", $output);
  $output = str_replace("{THIRDPAYER_DISABLED_END}", "-->", $output);
} else{ 
  $output = str_replace("{THIRDPAYER_DISABLED_START}", "", $output);
  $output = str_replace("{THIRDPAYER_DISABLED_END}", "", $output);
}

$_von_ad_country_options_ = addOptionsFromTable("phoenix_special.country","cou_iso_2","cou_iso_2","cou_iso_2","cou_continent = '1'","DE");
$_nach_ad_country_options_ = addOptionsFromTable("phoenix_special.country","cou_iso_2","cou_iso_2","cou_iso_2","cou_continent = '1'","DE");
$output = str_replace("{_von_ad_country_options_}", $_von_ad_country_options_, $output);
$output = str_replace("{_nach_ad_country_options_}", $_nach_ad_country_options_, $output);

// *** TABINDICES ***
$ti = 0;
$output = str_replace("{_von_cs_comp_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_person_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_ad_street_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_hsno_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_ad_country_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_ad_zipcode_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_ad_city_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_remark_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_cs_comp_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_tr_person_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_ad_street_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_tr_hsno_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_ad_country_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_ad_zipcode_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_ad_city_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_tr_remark_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_commission_no_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_commission_no_accesskey_}", _VON_TR_COMMISSION_NO_ACCESSKEY_, $output);
$output = str_replace("{_nach_tr_commission_no_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_tr_commission_no_accesskey_}", _NACH_TR_COMMISSION_NO_ACCESSKEY_, $output);
$output = str_replace("{_nach_tr_tracking_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_tracking_tabindex_}", ++$ti, $output);
$output = str_replace("{_tr_ware_from_von_tabindex_}", ++$ti, $output);
$output = str_replace("{_tr_ware_to_von_tabindex_}", ++$ti, $output);
$output = str_replace("{_tr_ware_from_nach_tabindex_}", ++$ti, $output);
$output = str_replace("{_tr_ware_to_nach_tabindex_}", ++$ti, $output);
$output = str_replace("{_payer_from_tabindex_}", ++$ti, $output);
$output = str_replace("{_payer_to_tabindex_}", ++$ti, $output);
$output = str_replace("{_vonFirmaButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_vonFirmaButton_accesskey_}", _VONFIRMABUTTON_ACCESSKEY_, $output);
$output = str_replace("{_vonAdressButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_vonAdressButton_accesskey_}", _VONADRESSBUTTON_ACCESSKEY_, $output);
$output = str_replace("{_von_tr_mediationarea_id_Button_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_remark_Button_tabindex_}", ++$ti, $output);
$output = str_replace("{_von_tr_remark_Button_accesskey_}", _VON_TR_REMARK_BUTTON_ACCESSKEY_, $output);
$output = str_replace("{_hide_von_tr_remark_tabindex_}", ++$ti, $output);
$output = str_replace("{_nachFirmaButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_nachFirmaButton_accesskey_}", _NACHFIRMABUTTON_ACCESSKEY_, $output);
$output = str_replace("{_nachAdressButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_nachAdressButton_accesskey_}", _NACHADRESSBUTTON_ACCESSKEY_, $output);
$output = str_replace("{_nach_tr_mediationarea_id_Button_tabindex_}", ++$ti, $output);
$output = str_replace("{_hide_nach_tr_remark_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_tr_remark_Button_tabindex_}", ++$ti, $output);
$output = str_replace("{_nach_tr_remark_Button_accesskey_}", _NACH_TR_REMARK_BUTTON_ACCESSKEY_, $output);
$output = str_replace("{_bezahlerFirmaButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_bezahlerFirmaButton_accesskey_}", _BEZAHLERFIRMABUTTON_ACCESSKEY_, $output);
$output = str_replace("{_jb_cash_tabindex_}", ++$ti, $output);
$output = str_replace("{_jb_cash_accesskey_}", _JB_CASH_ACCESSKEY_, $output);
$output = str_replace("{_jb_costsplit_tabindex_}", ++$ti, $output);
$output = str_replace("{_jb_costsplit_accesskey_}", _JB_COSTSPLIT_ACCESSKEY_, $output);
$output = str_replace("{_accept_all_addresses_tabindex_}", ++$ti, $output);
$output = str_replace("{_accept_all_addresses_accesskey_}", _ACCEPT_ALL_ADDRESSES_ACCESSKEY_, $output);
$output = str_replace("{_prevButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_prevButton_accesskey_}", _PREVBUTTON_ACCESSKEY_, $output);
$output = str_replace("{_waste1Button_tabindex_}", ++$ti, $output);
$output = str_replace("{_waste1Button_accesskey_}", _WASTE1BUTTON_ACCESSKEY_, $output);
$output = str_replace("{_switchButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_switchButton_accesskey_}", _SWITCHBUTTON_ACCESSKEY_, $output);
$output = str_replace("{_waste2Button_tabindex_}", ++$ti, $output);
$output = str_replace("{_waste2Button_accesskey_}", _WASTE2BUTTON_ACCESSKEY_, $output);
$output = str_replace("{_nextButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_nextButton_accesskey_}", _NEXTBUTTON_ACCESSKEY_, $output);
$output = str_replace("{_searchOldJobButton_tabindex_}", ++$ti, $output);
//$output = str_replace("{_searchOldJobButton_accesskey_}", _SEARCHOLDJOBBUTTON_ACCESSKEY_, $output);
$output = str_replace("{_duplicateJobButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_getLastJobButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_duplicateJobButton_accesskey_}", _DUPLICATEJOBBUTTON_ACCESSKEY_, $output);
$output = str_replace("{_jb_freetextButton_tabindex_}", ++$ti, $output);
$output = str_replace("{_jb_freetextButton_accesskey_}", _JB_FREETEXTBUTTON_ACCESSKEY_, $output);
// *** ***
//$tpl->parseCurrentBlock("touroptions");
//include("..\jobs\shrink.inc.php");
//$html_code = $tpl->get();
//echo htmlShrink($html_code, true);
//$tpl->show();
echo $output;
?>
