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

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

getSecHttpVars("1", array("csc_id_orderer"));
list ($what_is_this, $reload_couriers) = getHttpVars(array("what_is_this", "reload_couriers"));
if ($csc_id_orderer == "" && $csc_id_orderer != '0') reportDie ("$PHP_SELF: Parameter 'csc_id_orderer' fehlt!", false);
if ($csc_id_orderer != '0'):
  // Kundenaufrag
  $cs_id = getFieldValueFromId("costcenter", "csc_id", "$csc_id_orderer", "cs_id");
  $cmp_id = getFieldValueFromId("customer", "cs_id", "$cs_id", "cmp_id");
  $cmp_comp = getFieldValueFromId("company", "cmp_id", "$cmp_id", "cmp_comp");
  $csc_name = getFieldValueFromId("costcenter", "csc_id", "$csc_id_orderer", "csc_name");
else:
  // Zentralenauftrag
  $hq_id = $HTTP_SESSION_VARS['hq_id'];
  if ($hq_id_job != "")
    $hq_id = $hq_id_job;
  $cmp_id = getFieldValueFromId("headquarters", "hq_id", "$hq_id", "cmp_id");
  $cmp_comp = getFieldValueFromId("company", "cmp_id", "$cmp_id", "cmp_comp");
  $csc_name = getFieldValueFromId("company", "cmp_id", "$cmp_id", "cmp_comp2");
endif;

$_cr_id_order_list_ = "";
// $reload_couriers ist nur beim ersten Aufruf nicht gesetzt
if ($reload_couriers == "1"):
  include_once("job_courier.inc.php");
  $_cr_id_order_list_ =
    "function updateCr_id_order_list(){\n" .
    "var cr_id_order_list = new Array();\n" .
    $cr_id_order_list . 
    "parent.job_options.cr_id_order_list = cr_id_order_list;\n" .
    "parent.job_options.when = \"" . date("H:i") . "\";\n" .
    "parent.job_options.whenString = \"(Stand: <span style=\\\"color:red\\\">" . date("H:i") . "</span> Uhr)<br><br>\\n\";\n" .
    "}\n";
else:
  $_cr_id_order_list_ =
    "function updateCr_id_order_list(){\n" .
    "}\n";
endif;

$_kundenname_ = "";
$what_is_this_split = split(" ", $what_is_this);
$phpCurrentNavigationOnLoad = "";

if (trim($what_is_this_split[0]) == "Auftrags&auml;nderung" || trim($what_is_this_split[0]) == "Auftragsänderung"):
  $_kundenname_ = "<span style=\"color:red\">" . $what_is_this . " $cmp_comp ($csc_name)" . "</span>";
else:
  $_kundenname_ = $what_is_this . " $cmp_comp ($csc_name)";
  // dynamisches Ändern der Zentrale im Callcenter-Modus
  // Selection of the current usertype from session-variable
  $sqlquery = "SELECT usr_type FROM user"
               . " WHERE usr_id = " . $usr_id;
  $result = $db->query($sqlquery);
  if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
  $userType = "";
  while ($row = $result->fetch_assoc()):
        $userType = $row["usr_type"];
  endwhile;
  $result->free();
  
  $outHqSelection = "";
  if ($hq_id != "") :
    $empHqList = getParameterValue("0", "HEADQUARTERS_MULTIPLE_ACCESS_EMPLOYEES", "0");
    if ($userType == "1" && $empHqList != "") :
      $showMultipleHqSelection = isInParameterString($emp_id, $empHqList);
      if ($showMultipleHqSelection) :
        $tmpHqIdArray = getColVectorFromDB2ArrayByClause("headquarters", "hq_id", "", "", "hq_id", "");
        $tmpHqIdArrayLen = count($tmpHqIdArray);
        $outHqSelection .= "<div font-size:14pt; font-family:Helvetica,Arial; font-style:normal; font-weight:normal; vertical-align:middle;background-color:" . $constPageHeadlineBgCol . "; color:#FFFFFF\" name=\"currHqSelectionReduced\" id=\"currHqSelectionReduced\" onClick=\"myshow('currHqSelection'); myhide('currHqSelectionReduced');\">\n";
//        $outHqSelection .= "&nbsp;" . strtoupper(getFieldValueFromId("headquarters","hq_id",$hq_id,"hq_name")) . "&nbsp;:&nbsp;:&nbsp;" . strtoupper($what_is_this);
        $outHqSelection .= $_kundenname_;
        $outHqSelection .= "</div>\n";
        $outHqSelection .= "<div background-color:" . $constPageHeadlineBgCol . "; color:#FFFFFF\" name=\"currHqSelection\" id=\"currHqSelection\" onClick=\"myshow('currHqSelectionReduced'); myhide('currHqSelection');\">";
        for ($i = 0; $i < $tmpHqIdArrayLen; $i++) :
//            $outHqSelection .= "&nbsp;<a class=\"a_menu\" href=\"../admin/relogin.php?currReferer=" . urlencode(getCurrentScript($_SERVER['REQUEST_URI'])) . "&currHqSelection=" . ec($tmpHqIdArray[$i]) . "\">" . getFieldValueFromId("headquarters","hq_id",$tmpHqIdArray[$i],"hq_name") . "</a>&nbsp;&nbsp;";
//            $outHqSelection .= "&nbsp;<a class=\"a_menu\" href=\"../admin/relogin.php?currReferer=" . urlencode(getCurrentScript($_SERVER['HTTP_REFERER'])) . "&currHqSelection=" . ec($tmpHqIdArray[$i]) . "\">" . getFieldValueFromId("headquarters","hq_id",$tmpHqIdArray[$i],"hq_name") . "</a>&nbsp;&nbsp;";
            $outHqSelection .= "&nbsp;<a class=\"a_menu\" href=\"../admin/relogin.php?currReferer=" . urlencode("jobs/job_edit.php?currentNavigationItem=erfassung") . "&currHqSelection=" . ec($tmpHqIdArray[$i]) . "\" target=\"_parent\">" . getFieldValueFromId("headquarters","hq_id",$tmpHqIdArray[$i],"hq_name") . "</a>&nbsp;&nbsp;";
        endfor;
        $outHqSelection .= "</div>";
        $phpCurrentNavigationOnLoad = "myhide('currHqSelection'); myshow('currHqSelectionReduced');";
        $_kundenname_ = $outHqSelection;
      endif;
    endif;
  endif;
endif;

?>

<html>
<head>
<title>AUFTRAGSERFASSUNG</title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css.php">
<script src="../include/lib_global.js" type="text/javascript">
</script>

<script src="../include/key_events_content.js" language="JavaScript1.2" type="text/javascript">
</script>

<?php if ($phpCurrentNavigationOnLoad != "") include_once ("../include/js_framework.inc.php"); ?>

<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;

<?php echo $_cr_id_order_list_;?>

var auto_refresh = "<?php echo MASK_AUTO_REFRESH;?>";

function startTimeout()
{
<?php echo $phpCurrentNavigationOnLoad;?>
  if (auto_refresh == "1") {
    updateCr_id_order_list();
    self.setTimeout("startReload()", 60000);
  }
}

function startReload()
{
  self.location.href="job_header.php?csc_id_orderer=<?php echo ec($csc_id_orderer);?>&what_is_this=<?php echo $what_is_this;?>&reload_couriers=1";
}

-->
</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 onLoad="startTimeout()">
  <table border=0 height=95% width=100% align="center" cellspacing=0 cellpadding=0 vspace=0 hspace=0>
    <tr>
      <td width=10%>
        <img src="../images/empty.gif" border=0 height=2>
      </td>
      <td width=80%>
        <img src="../images/empty.gif" border=0 height=2>
      </td>
      <td width=10%>
        <img src="../images/empty.gif" border=0 height=2>
      </td>
    </tr>
    <tr>
      <td>
        &nbsp;
      </td>
      <td align="center" valign=center>
        <table border=0 height=95% width=100% align="center" cellspacing=0 cellpadding=0 vspace=0 hspace=0>
          <tr>
            <td align="center">
              <div class="f12bp1">
                <?php echo $_kundenname_;?>
              </div>
            </td>
          </tr>
        </table>
      </td>
      <td>
        &nbsp;
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="../images/empty.gif" border="0" height="2">
      </td>
    </tr>
  </table>
</body>
</html>
<script type="text/javascript">
<!--
  job_header_isLoading = false;
-->
</script>
