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

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


// Check HTTP-Parameters
getSecHttpVars("1",array("f_act", "customerId", "cscIdRoot", "cscIdActual", "f_cr_sid", "useRemoteDB"));


// Check for authentication access and granted rights
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "4", "1");

// ******************************************************
// Very special treatment for access to remote database
include_once ("../include/bwv.inc.php");
$remoteDBisActive = false;
if (BWV2_checkEmpRemoteDBAccess($useRemoteDB, $emp_id)) :
   $remoteDBisActive = BWV2_setRemoteDBAccessParameter();
endif;
// ******************************************************


// *********************************
// * Search MSISDN from courier-id *
// *********************************

// Get courier-id from the courier-sid (e.g. SIDs: 1013, 1019, etc.)
$cr_id = getFieldValueFromId("courier","cr_sid",$f_cr_sid,"cr_id");
$msisdn = getFieldValueFromId("courier","cr_id",$cr_id,"cr_mobile_pda");

// Remove blanks in MSISDN and check beginning with "49" 
// (IMPORTANT: No check for other chars because checked in javascript !!!)
$msisdn = ereg_replace (" ", "", $msisdn);
$msisdn = str_replace("+", "", $msisdn);
if (!ereg("^" . COUNTRY_FON_PREFIX, $msisdn)) : 
   if (ereg("^0", $msisdn)) :
      $msisdn = substr($msisdn, 1);
   endif;
   $msisdn = COUNTRY_FON_PREFIX . $msisdn;
endif;

// $locatingURL = "../locating/locating_tmobile.php";   // D1
// if (substr($msisdn, 0, 4) == "0173" || substr($msisdn, 0, 5) == "49173") :
//    $locatingURL = "../locating/locating_D2.php";   // D2
// endif;
$locatingURL = "../locating/locating_D2.php";   // D2
?>


<html lang="de">

<head>
<title>ORTUNGSWRAPPER</title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css"> 

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

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

-->
</script>
</head>


<body onLoad="javascript:doSubmit();">

  <form action="<?php echo $locatingURL ?>" method="post">
    
    <input type="hidden" name="f_act" value="<?php echo $f_act ?>">
    <input type="hidden" name="customerId" value="<?php echo $customerId ?>">
    <input type="hidden" name="cscIdRoot" value="<?php echo $cscIdRoot ?>">
    <input type="hidden" name="cscIdActual" value="<?php echo $cscIdActual ?>">
    <input type="hidden" name="f_cr_sid" value="<?php echo $f_cr_sid ?>">
    <input type="hidden" name="useRemoteDB" value="<?php echo $useRemoteDB ?>">
  </form>
  
</body>

</html>
