2850 lines
133 KiB
PHP
2850 lines
133 KiB
PHP
<?php
|
||
/*=======================================================================
|
||
*
|
||
* global.inc.php
|
||
*
|
||
* Autor: Marc Vollmann, Carsten Annacker
|
||
*
|
||
=======================================================================*/
|
||
|
||
include_once ("../include/dbglobal.inc.php");
|
||
include_once ("../include/email.inc.php");
|
||
|
||
|
||
// Get default settings according to the system language
|
||
$languageSelected = getParameterValue("0", "SYSTEM_LANGUAGE_DEFAULT", "0");
|
||
if ($languageSelected == "") :
|
||
$languageSelected = "0"; // Language selected ["0" = German, "1" = English, ...]
|
||
endif;
|
||
$languageDBUpdateMode = getParameterValue("0", "SYSTEM_LANGUAGE_AUTO_INSERT", "0");
|
||
if ($languageDBUpdateMode == "") :
|
||
$languageDBUpdateMode = "1"; // If activated (= "1") then check existence of language text in the database
|
||
endif;
|
||
|
||
|
||
getLanguage(__FILE__);
|
||
|
||
function getHttpVars($httpVars, $keepNL = true, $getSecHttpVarsMode = "0", $urldecodePost = false)
|
||
{
|
||
global $HTTP_GET_VARS, $HTTP_POST_VARS;
|
||
|
||
$retArr = array();
|
||
foreach($httpVars as $hVar)
|
||
$retArr[] =
|
||
(isset($HTTP_GET_VARS[$hVar]))
|
||
? ($getSecHttpVarsMode == "0"
|
||
? checkProblemChars($HTTP_GET_VARS[$hVar], $keepNL)
|
||
: $HTTP_GET_VARS[$hVar]
|
||
)
|
||
: ((isset($HTTP_POST_VARS[$hVar]))
|
||
? ($getSecHttpVarsMode == "0"
|
||
? ($urldecodePost
|
||
? urldecode(checkProblemChars($HTTP_POST_VARS[$hVar], $keepNL))
|
||
: checkProblemChars($HTTP_POST_VARS[$hVar], $keepNL)
|
||
)
|
||
: ($urldecodePost
|
||
? urldecode($HTTP_POST_VARS[$hVar])
|
||
: $HTTP_POST_VARS[$hVar]
|
||
)
|
||
)
|
||
: ""
|
||
);
|
||
return $retArr;
|
||
}
|
||
|
||
// Gets all script-parameters (HTTP_GET_VARS and HTTP_POST_VARS).
|
||
// If "$mode == 1" then all id-parameters (only these!) will be decoded
|
||
function getSecHttpVars($getSecHttpVarsMode = "0", $httpVars, $keepNL = true, $urldecodePost = false)
|
||
{
|
||
global $HTTP_GET_VARS, $HTTP_POST_VARS;
|
||
|
||
//print_r($HTTP_GET_VARS);
|
||
|
||
$retArr = getHttpVars($httpVars, $keepNL, $getSecHttpVarsMode, $urldecodePost);
|
||
$i = 0;
|
||
foreach ($httpVars as $par) {
|
||
global $$par;
|
||
|
||
//echo iconv("UTF-8", "ISO-8859-1//TRANSLIT", $retArr[$i]) . "<br>";
|
||
|
||
$$par = $retArr[$i];
|
||
$i++;
|
||
}
|
||
// Decryption of the fields if encrypted
|
||
foreach ($httpVars as $par) {
|
||
if ($getSecHttpVarsMode == "1" && !is_array($$par)) :
|
||
$$par = checkProblemChars(dc($$par), $keepNL);
|
||
endif;
|
||
}
|
||
return $retArr;
|
||
}
|
||
|
||
function getDbConnectionSpecial ($dbhost, $dbname, $dblogin, $dbpassword) {
|
||
global $PHP_SELF, $phpVersion;
|
||
|
||
$db_conn = "";
|
||
if ($phpVersion >= "8.0") :
|
||
$tmp = explode(":", $dbhost);
|
||
$dbhostOnly = $tmp[0];
|
||
$dbport = $tmp[1];
|
||
$dbCreds = array("dbHost" => $dbhostOnly, "dbUser" => $dblogin, "dbPassword" => $dbpassword, "dbName" => $dbname, "dbPort" => $dbport);
|
||
$db_conn = new DB($dbCreds);
|
||
$db_conn->dbQ('SET NAMES latin1');
|
||
$db_conn->dbQ('SET @@SESSION.old_passwords=0');
|
||
elseif ($phpVersion >= "7.0") :
|
||
$tmp = explode(":", $dbhost);
|
||
$dbhostOnly = $tmp[0];
|
||
$dbport = $tmp[1];
|
||
$dsn = array('phptype' => 'mysqli', 'username' => $dblogin, 'password' => $dbpassword, 'hostspec' => $dbhostOnly, 'port' => $dbport, 'database' => $dbname);
|
||
$dbOptions = array('ssl' => true);
|
||
$db_conn =& MDB2::connect($dsn, $dbOptions);
|
||
if (DB::isError($db_conn)) : die ("$PHP_SELF: " . $db_conn->getMessage()); endif;
|
||
if (DB::isError($db_conn)) return "ERR_DB";
|
||
$db_conn->setFetchMode(MDB2_FETCHMODE_ASSOC);
|
||
$db_conn->loadModule('Extended', null, false);
|
||
else :
|
||
$dsn = "mysql://$dblogin:$dbpassword@$dbhost/$dbname";
|
||
$db_conn = DB::connect($dsn, false);
|
||
if (DB::isError($db_conn)) return "ERR_DB";
|
||
$db_conn->setFetchMode(DB_FETCHMODE_ASSOC);
|
||
endif;
|
||
return $db_conn;
|
||
}
|
||
|
||
function getDbConnection ($dbhost, $dbname, $dblogin, $dbpassword) {
|
||
global $db, $PHP_SELF, $phpVersion;
|
||
|
||
if ($phpVersion >= "8.0") :
|
||
$tmp = explode(":", $dbhost);
|
||
$dbhostOnly = $tmp[0];
|
||
$dbport = $tmp[1];
|
||
$dbCreds = array("dbHost" => $dbhostOnly, "dbUser" => $dblogin, "dbPassword" => $dbpassword, "dbName" => $dbname, "dbPort" => $dbport);
|
||
$db = new DB($dbCreds);
|
||
elseif ($phpVersion >= "7.0") :
|
||
$tmp = explode(":", $dbhost);
|
||
$dbhostOnly = $tmp[0];
|
||
$dbport = $tmp[1];
|
||
$dsn = array('phptype' => 'mysqli', 'username' => $dblogin, 'password' => $dbpassword, 'hostspec' => $dbhostOnly, 'port' => $dbport, 'database' => $dbname);
|
||
$dbOptions = array('ssl' => true);
|
||
$db =& MDB2::connect($dsn, $dbOptions);
|
||
if (DB::isError($db)) :
|
||
die ("$PHP_SELF: " . $db->getMessage());
|
||
endif;
|
||
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
|
||
// $db->loadModule('Extended', null, false);
|
||
else :
|
||
$dsn = "mysql://$dblogin:$dbpassword@$dbhost/$dbname";
|
||
$db = DB::connect($dsn, false);
|
||
if (DB::isError($db)) die ("$PHP_SELF: " . $db->getMessage());
|
||
$db->setFetchMode(DB_FETCHMODE_ASSOC);
|
||
endif;
|
||
}
|
||
|
||
function getDb2Connection () {
|
||
global $db2, $db, $PHP_SELF, $phpVersion;
|
||
global $dbhost2,$dblogin2,$dbpassword2,$dbname2;
|
||
|
||
if ($phpVersion >= "8.0") :
|
||
$tmp = explode(":", $dbhost2);
|
||
$dbhostOnly2 = $tmp[0];
|
||
$dbport2 = $tmp[1];
|
||
$dbCreds = array("dbHost" => $dbhostOnly2, "dbUser" => $dblogin2, "dbPassword" => $dbpassword2, "dbName" => $dbname2, "dbPort" => $dbport2);
|
||
$db2 = new DB($dbCreds);
|
||
$db2->dbQ('SET NAMES latin1');
|
||
$db2->dbQ('SET @@SESSION.old_passwords=0');
|
||
elseif ($phpVersion >= "7.0") :
|
||
$tmp = explode(":", $dbhost2);
|
||
$dbhostOnly2 = $tmp[0];
|
||
$dbport2 = $tmp[1];
|
||
$dsn2 = array('phptype' => 'mysqli', 'username' => $dblogin2, 'password' => $dbpassword2, 'hostspec' => $dbhostOnly2, 'port' => $dbport2, 'database' => $dbname2);
|
||
$dbOptions2 = array('ssl' => true);
|
||
$db2 =& MDB2::connect($dsn2, $dbOptions2);
|
||
if (DB::isError($db2)) :
|
||
$db2 = $db;
|
||
else :
|
||
$db2->setFetchMode(MDB2_FETCHMODE_ASSOC);
|
||
$db2->loadModule('Extended', null, false);
|
||
endif;
|
||
else :
|
||
$dsn2 = "mysql://$dblogin2:$dbpassword2@$dbhost2/$dbname2";
|
||
$db2 = DB::connect($dsn2, false);
|
||
if (DB::isError($db2)) :
|
||
$db2 = $db;
|
||
else :
|
||
$db2->setFetchMode(DB_FETCHMODE_ASSOC);
|
||
endif;
|
||
endif;
|
||
}
|
||
|
||
function getDb3Connection () {
|
||
global $db3, $db, $PHP_SELF, $phpVersion;
|
||
global $dbhost3,$dblogin3,$dbpassword3,$dbname3;
|
||
|
||
if ($phpVersion >= "8.0") :
|
||
$tmp = explode(":", $dbhost3);
|
||
$dbhostOnly3 = $tmp[0];
|
||
$dbport3 = $tmp[1];
|
||
$dbCreds = array("dbHost" => $dbhostOnly3, "dbUser" => $dblogin3, "dbPassword" => $dbpassword3, "dbName" => $dbname3, "dbPort" => $dbport3);
|
||
$db3 = new DB($dbCreds);
|
||
$db3->dbQ('SET NAMES latin1');
|
||
$db3->dbQ('SET @@SESSION.old_passwords=0');
|
||
elseif ($phpVersion >= "7.0") :
|
||
$tmp = explode(":", $dbhost3);
|
||
$dbhostOnly3 = $tmp[0];
|
||
$dbport3 = $tmp[1];
|
||
$dsn3 = array('phptype' => 'mysqli', 'username' => $dblogin3, 'password' => $dbpassword3, 'hostspec' => $dbhostOnly3, 'port' => $dbport3, 'database' => $dbname3);
|
||
$dbOptions3 = array('ssl' => true);
|
||
$db3 =& MDB2::connect($dsn3, $dbOptions3);
|
||
if (DB::isError($db3)) :
|
||
$db3 = $db;
|
||
else :
|
||
$db3->setFetchMode(MDB2_FETCHMODE_ASSOC);
|
||
$db3->loadModule('Extended', null, false);
|
||
endif;
|
||
else :
|
||
$dsn3 = "mysql://$dblogin3:$dbpassword3@$dbhost3/$dbname3";
|
||
$db3 = DB::connect($dsn3, false);
|
||
if (DB::isError($db3)) :
|
||
$db3 = $db;
|
||
else :
|
||
$db3->setFetchMode(DB_FETCHMODE_ASSOC);
|
||
endif;
|
||
endif;
|
||
}
|
||
|
||
function getDbHistoryConnection ($db_conn) {
|
||
global $db, $PHP_SELF;
|
||
global $dbhost_history, $dblogin_history, $dbpassword_history, $dbname_history, $dbport_history;
|
||
|
||
if (!is_object($db_conn) || $db_conn == "") :
|
||
$db_conn = getDbConnectionSpecial($dbhost_history, $dbname_history, $dblogin_history, $dbpassword_history, $dbport_history);
|
||
endif;
|
||
return $db_conn;
|
||
}
|
||
|
||
// Get absolute system path (e.g. "/data0/srv/www/htsdocs/xxxx")
|
||
function getAbsoluteSystemPath () {
|
||
$dirName = dirname(__FILE__);
|
||
$dirName = str_replace("\\", "/", $dirName);
|
||
$lastSlashPos = strrpos($dirName,"/");
|
||
$path = substr($dirName, 0, $lastSlashPos);
|
||
return $path;
|
||
}
|
||
|
||
// Triggers the script for sending an internal mail
|
||
function sendInternalMail ($errMsg) {
|
||
if ($errMsg != "") :
|
||
$path = getAbsoluteSystemPath();
|
||
$result = "";
|
||
$cmd = "php " . $path . "/include/automailer_internal.php comegetsome97531 \"" . $errMsg . "\" &";
|
||
exec($cmd . " > /dev/null &");
|
||
endif;
|
||
}
|
||
|
||
// Triggers the script for sending an external mail
|
||
function sendExternalMail ($mailText, $mailSubject, $mailTo, $mailFrom = "", $mailCc = "", $mailBcc = "", $mailMode = "", $mailLogContent = "", $mailLogFile = "") {
|
||
global $debug;
|
||
if ($mailText != "" && $mailSubject != "" && $mailTo != "") :
|
||
if ($mailFrom == "") : $mailFrom = "EMPTY"; endif;
|
||
if ($mailCc == "") : $mailCc = "EMPTY"; endif;
|
||
if ($mailBcc == "") : $mailBcc = "EMPTY"; endif;
|
||
if ($mailMode == "") : $mailMode = "EMPTY"; endif;
|
||
if ($mailLogContent == "") : $mailLogContent = "EMPTY"; endif;
|
||
if ($mailLogFile == "") : $mailLogFile = "EMPTY"; endif;
|
||
$path = getAbsoluteSystemPath();
|
||
if ($debug) :
|
||
echo "path = " . $path . "<br>";
|
||
echo "mailText = " . $mailText . "<br>";
|
||
echo "mailSubject = " . $mailSubject . "<br>";
|
||
echo "mailTo = " . $mailTo . "<br>";
|
||
echo "mailFrom = " . $mailFrom . "<br>";
|
||
echo "mailCc = " . $mailCc . "<br>";
|
||
echo "mailBcc = " . $mailBcc . "<br>";
|
||
echo "mailMode = " . $mailMode . "<br>";
|
||
echo "mailLogContent = " . $mailLogContent . "<br>";
|
||
echo "mailLogFile = " . $mailLogFile . "<br>";
|
||
// die();
|
||
endif;
|
||
$result = "";
|
||
$cmd = "php " . $path . "/include/automailer_external.php comegetsome97531 \"" . urlencode($mailText) . "\" \"" . urlencode($mailSubject) . "\" " . $mailTo . " " . $mailFrom . " " . $mailCc . " " . $mailBcc . " " . $mailMode . " " . urlencode($mailLogContent) . " " . $mailLogFile . " &";
|
||
exec($cmd . " > /dev/null &");
|
||
endif;
|
||
}
|
||
|
||
// Get instance of external metaobject database
|
||
function getExternalMetaDbInst () {
|
||
$constExtDbInst = getParameterValue("0", "EXTERNAL_DB_METAOBJECT", "0", "0");
|
||
if ($constExtDbInst == "") : $constExtDbInst = "172.16.0.111:3711"; endif;
|
||
return $constExtDbInst;
|
||
}
|
||
|
||
// Gets the connection to the central meta objects table
|
||
function getConnectionToMetaDB ($dbName = "meta_object", $tableName = "metaobject", $sendInternalMail = true) {
|
||
global $dblogin, $dbpassword;
|
||
// $defValMysqlConnectTimeout = ini_set('mysql.connect_timeout', 5);
|
||
$constExtDbInst = getParameterValue("0", "EXTERNAL_DB_METAOBJECT", "0", "0");
|
||
$db_conn = getDbConnectionSpecial($constExtDbInst, $dbName, $dblogin, $dbpassword);
|
||
if ($db_conn == "ERR_DB") :
|
||
// Check cascade of replicants
|
||
$constExtDbInst = "172.16.0.111:3711";
|
||
$db_conn = getDbConnectionSpecial($constExtDbInst, $dbName, $dblogin, $dbpassword);
|
||
if ($db_conn == "ERR_DB") :
|
||
$constExtDbInst = "172.16.0.109:3711";
|
||
$db_conn = getDbConnectionSpecial($constExtDbInst, $dbName, $dblogin, $dbpassword);
|
||
if ($db_conn == "ERR_DB") :
|
||
$constExtDbInst = "172.16.0.103:3711";
|
||
$db_conn = getDbConnectionSpecial($constExtDbInst, $dbName, $dblogin, $dbpassword);
|
||
endif;
|
||
endif;
|
||
// Send info mail
|
||
if ($db_conn == "ERR_DB" && $sendInternalMail) :
|
||
sendInternalMail("metaobject_db_fail");
|
||
endif;
|
||
endif;
|
||
// ini_set('mysql.connect_timeout', $defValMysqlConnectTimeout);
|
||
return $db_conn;
|
||
}
|
||
|
||
// Gets all databases and its IPs and ports listed in the central meta objects table
|
||
function getGlobalDbEnvironments ($dbName = "meta_object", $tableName = "metaobject", $sendInternalMail = true) {
|
||
$dbhostArray = array();
|
||
$db_conn = getConnectionToMetaDB($dbName, $tableName, $sendInternalMail);
|
||
if ($db_conn != "ERR_DB") :
|
||
$sqlquery = "SELECT mo_mnemonic, mo_value FROM " . $dbName . "." . $tableName . " AS mo WHERE mo_obj_type = 'db' AND mo_mnemonic != ''";
|
||
$result = $db_conn->dbQ($sqlquery);
|
||
while ($row = $result->fetch_assoc()):
|
||
$dbhostArray[$row["mo_mnemonic"]] = $row["mo_value"];
|
||
endwhile;
|
||
$result->free();
|
||
endif;
|
||
return $dbhostArray;
|
||
}
|
||
|
||
function checkProblemChars($aStr, $keepNL = true) {
|
||
|
||
if (is_array($aStr)) {
|
||
foreach ($aStr as &$value) {
|
||
$value = checkProblemChars($value, $keepNL);
|
||
}
|
||
unset($value);
|
||
} else {
|
||
//writeLog_("../log/checkProblemChars_", "checkProblemChars: \$aStr = " . $aStr . ", \$keepNL = " . $keepNL);
|
||
$aStr = preg_replace('/[\x01\x02\x03\x04\x05\x06\a\b\t\x0B\f\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\e\x1C\x1D\x1E\x1F]+/', '', $aStr);
|
||
$aStr = preg_replace('/[\x5C\x7F\x81\x8D\x8E\x8F\x90\x9D]+/', '', $aStr);
|
||
$aStr = preg_replace(array('/€/', '/
[0-9];/', '/[0-9];/', '/[0-9];/'), '', $aStr);
|
||
if (!$keepNL) {
|
||
$aStr = preg_replace('/[\n\r]+/', '', $aStr);
|
||
} else {
|
||
$aStr = preg_replace('/[\r]+/', '', $aStr);
|
||
// $aStr = preg_replace('/\R+/', "\n", $aStr);
|
||
}
|
||
//https://de.wikipedia.org/wiki/Windows-1252
|
||
// €<3B>‚ƒ„…†‡ˆ‰Š‹Œ<3B>Ž<3B><>‘’“”•–—˜™š›œ<3B>žŸ
|
||
//writeLog_("../log/checkProblemChars_", "checkProblemChars: \$aStr = " . $aStr);
|
||
}
|
||
|
||
return $aStr;
|
||
}
|
||
|
||
// Apostrophe und Kaufmanns-Und führen zu Problemen auf den Endgeräten
|
||
function my_str_check_mobile($aStr, $keepNL = true)
|
||
{
|
||
global $hq_id;
|
||
|
||
//¹²Â dürfen in der Auftragserfassung nicht vorkommen
|
||
|
||
// $aStr = str_replace("\\", '\\\\', $aStr);
|
||
// $aStr = str_replace('\'', '´', $aStr);
|
||
$aStr = str_replace('\'', "\\'", $aStr);
|
||
// $aStr = str_replace('&', '+', $aStr);
|
||
if (MASK_CR_PRICE_MODE == "1" && getParameterValue("0", "MASK_CR_PRICE_MODE_CHECK_CHARS", $hq_id) == "1") {
|
||
// 18.04.2023: Notmaßnahme wg. Zeichensatzprobleme
|
||
$aStr = strtr($aStr, array("ä" => "ae", "ö" => "oe", "ü" => "ue", "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue", "ß" => "ss"));
|
||
for ($pos = 0; $pos < strlen($aStr); $pos++) {
|
||
$byte = substr($aStr, $pos);
|
||
if (ord($byte) == 128)
|
||
$aStr = str_replace(chr(ord($byte)), "EUR", $aStr);
|
||
if (ord($byte) > 128)
|
||
$aStr = str_replace(chr(ord($byte)), "?", $aStr);
|
||
}
|
||
}
|
||
return $aStr;
|
||
}
|
||
|
||
function my_str_check($aStr)
|
||
{
|
||
$aStr = str_replace('\'', '\\\'', $aStr);
|
||
$aStr = str_replace("\"", '\\"', $aStr);
|
||
$aStr = str_replace("\n", '\\n', $aStr);
|
||
$aStr = str_replace("\r", '\\r', $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
// In http-vars, " and ' are already escaped!
|
||
function my_str_check_http($aStr)
|
||
{
|
||
$aStr = str_replace("\n", '\\n', $aStr);
|
||
$aStr = str_replace("\r", '\\r', $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function my_str_check_js($aStr)
|
||
{
|
||
$aStr = str_replace('\'', '\\\'', $aStr);
|
||
$aStr = str_replace("\"", '', $aStr);
|
||
$aStr = str_replace("\n", '\\n', $aStr);
|
||
$aStr = str_replace("\r", '\\r', $aStr);
|
||
// falls das Euro-Zeichen hier nicht als utf-8 gelandet ist
|
||
// $aStr = str_replace(chr(0x80), "\u{20ac}", $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function my_str_check_html($aStr)
|
||
{
|
||
$aStr = str_replace("\"", '"', $aStr);
|
||
$aStr = str_replace("<", '<', $aStr);
|
||
$aStr = str_replace(">", '>', $aStr);
|
||
$aStr = str_replace(">", '&', $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function strWrapHtml($aStr)
|
||
{
|
||
$aStr = str_replace("\\", "", $aStr);
|
||
$aStr = str_replace("\"", '"', $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function strWrapJs($aStr)
|
||
{
|
||
$aStr = str_replace("'", "\'", $aStr);
|
||
$aStr = str_replace("\"", '', $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function br2nl($aStr)
|
||
{
|
||
$aStr = str_replace("<br />", "\n", $aStr);
|
||
$aStr = str_replace("<br />", "", $aStr);
|
||
$aStr = my_str_check_js($aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function escapeMysqlForBinary($aStr) {
|
||
$aStr = str_replace("\\", '\\\\', $aStr);
|
||
$aStr = str_replace('\'', '\\\'', $aStr);
|
||
$aStr = str_replace("\"", '\\"', $aStr);
|
||
$aStr = str_replace("\0", '\\0', $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function my_char_conversion($aStr) {
|
||
$aStr = str_replace("ä", "ä", $aStr);
|
||
$aStr = str_replace("ö", "ö", $aStr);
|
||
$aStr = str_replace("ü", "ü", $aStr);
|
||
$aStr = str_replace("Ä", "Ä", $aStr);
|
||
$aStr = str_replace("Ö", "Ö", $aStr);
|
||
$aStr = str_replace("Ü", "Ü", $aStr);
|
||
$aStr = str_replace("ß", "ß", $aStr);
|
||
$aStr = str_replace("å", "å", $aStr);
|
||
$aStr = str_replace("Å", "Å", $aStr);
|
||
$aStr = str_replace("É", "É", $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function my_nl2br($aStr)
|
||
{
|
||
$aStr = str_replace("\r\n", '</br>', $aStr);
|
||
$aStr = str_replace("\n\r", '</br>', $aStr);
|
||
$aStr = str_replace("\r", '</br>', $aStr);
|
||
$aStr = str_replace("\n", '</br>', $aStr);
|
||
return $aStr;
|
||
}
|
||
|
||
function compress ($raw, $level = 9, $supports = null) {
|
||
return gzdeflate($raw, $level);
|
||
}
|
||
|
||
function uncompress ($compressed, $func = "") {
|
||
if ($func == "" || $func == "gzinflate") :
|
||
$decompressed = gzinflate($compressed);
|
||
if (false !== $decompressed) :
|
||
return $decompressed;
|
||
endif;
|
||
endif;
|
||
if ($func == "" || $func == "gzuncompress") :
|
||
$decompressed = gzuncompress($compressed);
|
||
if (false !== $decompressed) :
|
||
return $decompressed;
|
||
endif;
|
||
endif;
|
||
if ($func == "" || $func == "gzdecode") :
|
||
if (function_exists('gzdecode')) :
|
||
$decompressed = gzdecode($compressed);
|
||
if (false !== $decompressed) :
|
||
return $decompressed;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
return $compressed;
|
||
}
|
||
|
||
// Checks the password
|
||
function checkPasswordValidation($password,$password2) {
|
||
global $statusMessage;
|
||
$retVal = FALSE;
|
||
if ($password == $password2) :
|
||
if (strlen($password) >= 8) :
|
||
if (ereg ("[0-9]", $password)) :
|
||
if (ereg ("[a-zA-Z]", $password)) :
|
||
$retVal = TRUE;
|
||
else :
|
||
$statusMessage = getLngt("Das Passwort muss mindestens einen Buchstaben enthalten!");
|
||
endif;
|
||
else :
|
||
$statusMessage = getLngt("Das Passwort muss mindestens eine Zahl enthalten!");
|
||
endif;
|
||
else :
|
||
$statusMessage = getLngt("Das Passwort muss mindestens 8 Zeichen lang sein!");
|
||
endif;
|
||
else :
|
||
$statusMessage = getLngt("Die Eingaben in den beiden Passwortfeldern sind nicht identisch!");
|
||
endif;
|
||
return $retVal;
|
||
};
|
||
|
||
// Format mobile number
|
||
function eregPhoneNo ($phoneNo) {
|
||
global $hq_id;
|
||
// Get phone prefix of the country
|
||
$parCountryPhonePrefix = getParameterValue("0", "COUNTRY_FON_PREFIX", $hq_id);
|
||
if ($parCountryPhonePrefix == "") :
|
||
$parCountryPhonePrefix = getParameterValue("0", "COUNTRY_FON_PREFIX", "0");
|
||
if ($parCountryPhonePrefix == "") :
|
||
$parCountryPhonePrefix = "49";
|
||
endif;
|
||
endif;
|
||
// Prepare
|
||
if ($phoneNo != "") :
|
||
$phoneNo = preg_replace ("/ /", "", $phoneNo); // Remove blanks
|
||
$phoneNo = preg_replace ("/-/", "", $phoneNo); // Remove sign "-"
|
||
$phoneNo = preg_replace ("/^\+/", "00", $phoneNo); // Remove country prefix sign "+" with "00"
|
||
$phoneNo = preg_replace ("/^00" . $parCountryPhonePrefix . "/", "0", $phoneNo); // Remove country prefix with "0"
|
||
$phoneNo = preg_replace ("/^00/", "", $phoneNo); // Remove leading "00"
|
||
$phoneNo = preg_replace ("/^0/", "", $phoneNo); // Remove leading "0"
|
||
endif;
|
||
return $phoneNo;
|
||
}
|
||
|
||
// Checks accessibility to mandator administration
|
||
function getSQLMandatorPhrase($empId, $sqlPhrase) {
|
||
$retPhrase = " " . $sqlPhrase . " ";
|
||
if (authCheckEmployeeRights($empId, "10")) :
|
||
$retPhrase = ""; // Access granted => no restiction in SQL phrase according to "hq_id"
|
||
endif;
|
||
return $retPhrase;
|
||
};
|
||
|
||
// Checks accessibility to mandator administration
|
||
function getSQLMandatorArray($hqIdArray) {
|
||
global $hq_id;
|
||
if ($hqIdArray == "") : $hqIdArray = array(); endif;
|
||
if (!is_array($hqIdArray) && $hqIdArray != "") : $hqIdArray = array($hqIdArray); endif;
|
||
$hqIdArrayLen = count($hqIdArray);
|
||
if ($hqIdArrayLen == 0) :
|
||
$retPhrase = " (" . $hq_id . ") ";
|
||
else :
|
||
$retPhrase = " (" . implode(",", $hqIdArray) . ") ";
|
||
endif;
|
||
return $retPhrase;
|
||
};
|
||
|
||
// Decision to use the job archive or normal tables
|
||
function getDBNames($dbhistory, $yearFrom = "") {
|
||
global $dbh_jb, $dbh_tr, $dbh_trs, $dbh_jbp, $dbh_log, $dbh_cdt, $dbh_jbc, $dbh_trat, $dbh_tratp;
|
||
$dbh_jb = "job"; $dbh_tr = "tour"; $dbh_trs = "tourservice"; $dbh_log = "log"; $dbh_cdt = "courierdatatransfer"; $dbh_trat = "tourarticle"; $dbh_tratp = "tourarticleprocess";
|
||
$dbh_jbc = "jobcalculator"; $dbh_jbp = "jobpayment";
|
||
if ($dbhistory == "1") :
|
||
$dbh_jb = "jobhistory"; $dbh_tr = "tourhistory"; $dbh_trs = "tourservicehistory"; $dbh_log = "loghistory";
|
||
$dbh_cdt = "phoenix_pda.courierdatatransferhistory"; $dbh_jbc = "jobcalculatorhistory"; $dbh_jbp = "jobpaymenthistory";
|
||
$dbh_trat = "tourarticle"; $dbh_tratp = "tourarticleprocess";
|
||
// Check for another history level 2
|
||
if ($yearFrom != "" && is_numeric($yearFrom)) :
|
||
$constYearOfBeginHistory2 = getParameterValue("0", "STATISTIC_YEAR_OF_BEGIN_HISTORY_2", "0");
|
||
if ($constYearOfBeginHistory2 != "" && is_numeric($constYearOfBeginHistory2)) :
|
||
if ($yearFrom <= $constYearOfBeginHistory2) :
|
||
$dbhistory = "2";
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
// Set history level 2
|
||
if ($dbhistory == "2") :
|
||
$dbh_jb = "jobhistory2"; $dbh_tr = "tourhistory2"; $dbh_trs = "tourservicehistory2"; $dbh_log = "loghistory2";
|
||
$dbh_cdt = "phoenix_pda.courierdatatransferhistory"; $dbh_jbc = "jobcalculatorhistory"; $dbh_jbp = "jobpaymenthistory";
|
||
$dbh_trat = "tourarticle"; $dbh_tratp = "tourarticleprocess";
|
||
// Check for another history level 3
|
||
if ($yearFrom != "" && is_numeric($yearFrom)) :
|
||
$constYearOfBeginHistory3 = getParameterValue("0", "STATISTIC_YEAR_OF_BEGIN_HISTORY_3", "0");
|
||
if ($constYearOfBeginHistory3 != "" && is_numeric($constYearOfBeginHistory3)) :
|
||
if ($yearFrom <= $constYearOfBeginHistory3) :
|
||
$dbhistory = "3";
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
// Set history level 3
|
||
if ($dbhistory == "3") :
|
||
$dbh_jb = "jobhistory3"; $dbh_tr = "tourhistory3"; $dbh_trs = "tourservicehistory3"; $dbh_log = "loghistory3";
|
||
$dbh_cdt = "phoenix_pda.courierdatatransferhistory"; $dbh_jbc = "jobcalculatorhistory"; $dbh_jbp = "jobpaymenthistory";
|
||
$dbh_trat = "tourarticle"; $dbh_tratp = "tourarticleprocess";
|
||
endif;
|
||
return $dbhistory;
|
||
};
|
||
|
||
// Checks an gets the value for $dbhistory
|
||
function checkHistoryLevel ($dbhistory, $objType, $objId) {
|
||
global $dbh_jb, $dbh_tr, $dbh_trs, $dbh_jbp, $dbh_log, $dbh_cdt, $dbh_jbc, $dbh_trat, $dbh_tratp;
|
||
if ($dbhistory == "1" && $objType != "" && $objId != "") :
|
||
getDBNames($dbhistory);
|
||
if ($objType == "jb") :
|
||
$jbHqId = getFieldValueFromId($dbh_jb, "jb_id", $objId, "hq_id");
|
||
if ($jbHqId == "") :
|
||
$dbhistory = "2";
|
||
getDBNames($dbhistory);
|
||
$jbHqId = getFieldValueFromId($dbh_jb, "jb_id", $objId, "hq_id");
|
||
if ($jbHqId == "") :
|
||
$dbhistory = "3";
|
||
getDBNames($dbhistory);
|
||
// ...
|
||
// Fallback, reset value to start value
|
||
$jbHqId = getFieldValueFromId($dbh_jb, "jb_id", $objId, "hq_id");
|
||
if ($jbHqId == "") :
|
||
$dbhistory = "1";
|
||
getDBNames($dbhistory);
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
return $dbhistory;
|
||
};
|
||
|
||
// Get the actual DATETIME (e.g. according to the scheme needed in MySql)
|
||
function getDateTime($mode = "0", $dateTimeArray = "", $formatStr = "") {
|
||
$retVal = "";
|
||
if ($mode == "0") : $retVal = date("Y-m-d H:i:s"); endif; // 2003-03-10 17:16:17
|
||
if ($mode == "1") : $retVal = date("Ymd"); endif; // 20030310
|
||
if ($mode == "2") : $retVal = date("m.d.y"); endif; // 03.10.01
|
||
if ($mode == "3") : $retVal = date("Y-m-d"); endif; // 2003-03-10
|
||
if ($mode == "4") : $retVal = date("H:i:s"); endif; // 17:16:17
|
||
if ($mode == "5") : $retVal = date("d.m.Y"); endif; // 10.03.2003
|
||
if ($mode == "6") : $retVal = date("YmdHis"); endif; // 20030310171617
|
||
if ($mode == "7") : $retVal = date("dmY"); endif; // 31122003
|
||
|
||
if ($mode == "day") : $retVal = date("d"); endif; // 01 .. 31
|
||
if ($mode == "month") : $retVal = date("m"); endif; // 01 .. 12
|
||
if ($mode == "year") : $retVal = date("Y"); endif; // 2003, ...
|
||
if ($mode == "hour") : $retVal = date("H"); endif; // 00 .. 11
|
||
if ($mode == "minute") : $retVal = date("i"); endif; // 00 .. 59
|
||
if ($mode == "second") : $retVal = date("s"); endif; // 00 .. 59
|
||
|
||
if ($mode == "now") : $retVal = date("YmdHis", mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("y"))); endif; // 20090807105959
|
||
|
||
if ($mode == "day_tomorrow") : $retVal = date("d",mktime(0,0,0,date("m"),date("d")+1,date("Y"))); endif; // 01 .. 31
|
||
if ($mode == "month_tomorrow") : $retVal = date("m",mktime(0,0,0,date("m"),date("d")+1,date("Y"))); endif; // 01 .. 12
|
||
if ($mode == "year_tomorrow") : $retVal = date("Y",mktime(0,0,0,date("m"),date("d")+1,date("Y"))); endif; // 2003, ...
|
||
|
||
if ($mode == "day_yesterday") : $retVal = date("d",mktime(0,0,0,date("m"),date("d")-1,date("Y"))); endif; // 01 .. 31
|
||
if ($mode == "month_yesterday") : $retVal = date("m",mktime(0,0,0,date("m"),date("d")-1,date("Y"))); endif; // 01 .. 12
|
||
if ($mode == "year_yesterday") : $retVal = date("Y",mktime(0,0,0,date("m"),date("d")-1,date("Y"))); endif; // 2003, ...
|
||
|
||
if ($mode == "date_plus_offset") :
|
||
$retVal = date($formatStr, mktime(0,0,0,date("m")+$dateTimeArray[0],date("d")+$dateTimeArray[1],date("Y")+$dateTimeArray[2]));
|
||
endif;
|
||
|
||
if ($mode == "datetime_plus_offset") :
|
||
$retVal = date($formatStr, mktime(date("H")+$dateTimeArray[0],date("i")+$dateTimeArray[1],date("s")+$dateTimeArray[2],date("m")+$dateTimeArray[3],date("d")+$dateTimeArray[4],date("Y")+$dateTimeArray[5]));
|
||
endif;
|
||
|
||
if ($mode == "lastmonth") : $retVal = date("m",mktime(0,0,0,date("m")-1,date("d"),date("Y"))); endif; // 01 .. 12
|
||
|
||
if ($mode == "lastyear") : $retVal = date("Y",mktime(0, 0, 0, date("m"),date("d"),date("Y")-1)); endif; // 2002, ...
|
||
if ($mode == "nextyear") : $retVal = date("Y",mktime(0, 0, 0, date("m"),date("d"),date("Y")+1)); endif; // 2004, ...
|
||
|
||
if ($mode == "date_lastyear") : $retVal = date("Y-m-d",mktime(0, 0, 0, date("m"),date("d"),date("Y")-1)); endif; // 2002-03-10, ...
|
||
|
||
// Current year
|
||
if ($mode == "date_firstday_firstmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,1,1,date("Y"))); endif; // 2015-01-01, ...
|
||
if ($mode == "date_yesterday_currentmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-1,date("Y"))); endif; // 2015-05-25, ...
|
||
if ($mode == "date_firstday_currentmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m"),1,date("Y"))); endif; // 2015-05-01, ...
|
||
if ($mode == "date_lastday_currentmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")+1,0,date("Y"))); endif; // 2015-05-31, ...
|
||
if ($mode == "date_yesterday_lastmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-1,date("d")-1,date("Y"))); endif; // 2015-04-25, ...
|
||
if ($mode == "date_firstday_lastmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-1,1,date("Y"))); endif; // 2015-04-01, ...
|
||
if ($mode == "date_lastday_lastmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m"),0,date("Y"))); endif; // 2015-04-31, ...
|
||
if ($mode == "date_yesterday_nexttolastmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-2,date("d")-1,date("Y"))); endif; // 2015-03-25, ...
|
||
if ($mode == "date_firstday_nexttolastmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-2,1,date("Y"))); endif; // 2015-03-01, ...
|
||
if ($mode == "date_lastday_nexttolastmonth_currentyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-1,0,date("Y"))); endif; // 2015-03-31, ...
|
||
|
||
// Last year
|
||
if ($mode == "date_firstday_firstmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,1,1,date("Y")-1)); endif; // 2014-01-01, ...
|
||
if ($mode == "date_yesterday_currentmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-1,date("Y")-1)); endif; // 2014-05-25, ...
|
||
if ($mode == "date_firstday_currentmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m"),1,date("Y")-1)); endif; // 2014-04-01, ...
|
||
if ($mode == "date_yesterday_lastmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-1,date("d")-1,date("Y")-1)); endif; // 2014-04-25, ...
|
||
if ($mode == "date_firstday_lastmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-1,1,date("Y")-1)); endif; // 2015-05-01, ...
|
||
if ($mode == "date_lastday_lastmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m"),0,date("Y")-1)); endif; // 2015-05-31, ...
|
||
if ($mode == "date_yesterday_nexttolastmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-2,date("d")-1,date("Y")-1)); endif; // 2014-04-25, ...
|
||
if ($mode == "date_firstday_nexttolastmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-2,1,date("Y")-1)); endif; // 2015-05-01, ...
|
||
if ($mode == "date_lastday_nexttolastmonth_lastyear") : $retVal = date("Y-m-d",mktime(0,0,0,date("m")-1,0,date("Y")-1)); endif; // 2015-05-31, ...
|
||
|
||
if ($mode == "format" && $dateTimeArray != "" && $formatStr != "") :
|
||
// int mktime ( [int Stunde [, int Minute [, int Sekunde [, int Monat [, int Tag [, int Jahr [, int is_dst]]]]]]])
|
||
$retVal = date($formatStr, mktime($dateTimeArray[0],$dateTimeArray[1],$dateTimeArray[2],$dateTimeArray[3],$dateTimeArray[4],$dateTimeArray[5]));
|
||
endif;
|
||
|
||
return $retVal;
|
||
}
|
||
|
||
// Returns the number of days between two dates
|
||
function mcDateDiff($date1, $date2, $mode = "0") {
|
||
$retVal = "";
|
||
$unixTS1 = mktime(0,0,0,substr($date1,5,2),substr($date1,8,2),substr($date1,0,4));
|
||
$unixTS2 = mktime(0,0,0,substr($date2,5,2),substr($date2,8,2),substr($date2,0,4));
|
||
$retVal = $unixTS2 - $unixTS1;
|
||
if ($mode == "0") :
|
||
$retVal = ($retVal / 86400); // Return number of days
|
||
endif;
|
||
return $retVal;
|
||
}
|
||
|
||
// Fills up a string (default on the left) with a specified number of chars
|
||
// $strValue : String to be filled up
|
||
// $lengthOf : Length to fill up (if 0 then trim($strValue))
|
||
// $specialChar : Char to append
|
||
function pad($strValue = "", $lengthOf = 0, $specialChar = "0", $appendMode = "left") {
|
||
if ($lengthOf == 0 || ($appendMode != "left" && $appendMode != "right")) :
|
||
return trim($strValue);
|
||
endif;
|
||
|
||
$len = strlen($strValue);
|
||
for ($i = $len; $i < $lengthOf; $i++) :
|
||
if ($appendMode == "left") :
|
||
$strValue = $specialChar . $strValue;
|
||
else :
|
||
$strValue = $strValue . $specialChar;
|
||
endif;
|
||
endfor;
|
||
return $strValue;
|
||
}
|
||
|
||
function padCenter($strValue = "", $lengthOf = 0, $specialChar = "0") {
|
||
if ($lengthOf == 0 || !is_numeric($lengthOf)) :
|
||
return trim($strValue);
|
||
endif;
|
||
|
||
$len = strlen($strValue);
|
||
$lengthOf = floor($lengthOf / 2);
|
||
for ($i = 0; $i < $lengthOf; $i++) :
|
||
$strValue = $specialChar . $strValue . $specialChar;
|
||
endfor;
|
||
return $strValue;
|
||
}
|
||
|
||
// Gets an associative array (key <-> value) from a given string
|
||
// E.g.: "SID=1099|CR_VHT_ID=3|JB_VHT_ID=2|LOST_RANKING=YES..." => x(SID)=1099, x(CR_VHT_ID) = 3, ...
|
||
function getKeyValueArrayFromString($strToSplit, $delimiter = "|", $delimiter2 = "=") {
|
||
$retArray = array();
|
||
if ($strToSplit != "") :
|
||
// $strToSplit = ereg_replace ($delimiter, "-,-", $strToSplit);
|
||
$strToSplit = str_replace($delimiter, "-,-", $strToSplit);
|
||
if (!(strpos($strToSplit, "-,-") === FALSE)) :
|
||
$tmp = spliti("-,-",$strToSplit);
|
||
else :
|
||
$tmp = array($strToSplit);
|
||
endif;
|
||
$lenTmp = count($tmp);
|
||
for ($i = 0; $i < $lenTmp; $i++) {
|
||
if (!(strpos($tmp[$i], $delimiter2) === FALSE)) :
|
||
// $tmp2 = spliti("$delimiter2",$tmp[$i]);
|
||
$tmp2 = spliti($delimiter2,$tmp[$i]);
|
||
if ($tmp2[1] != "") :
|
||
$retArray[$tmp2[0]] = $tmp2[1];
|
||
endif;
|
||
endif;
|
||
}
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
// Gets an associative array (key <-> value) from a given string
|
||
// E.g.: "SID=1099|CR_VHT_ID=3|JB_VHT_ID=2|LOST_RANKING=YES..." => x(SID)=1099, x(CR_VHT_ID) = 3, ....
|
||
// like "getKeyValueArrayFromString" but "....|key=blah1=blah2=blah3=blah4|...." will deliver x(key)=blah1=blah2=blah3=blah4 and NOT x(key)=blah1 only (!!!!)
|
||
function getKeyValueArrayFromMultiDelimiterString($strToSplit, $delimiter = "|", $delimiter2 = "=") {
|
||
$retArray = array();
|
||
if ($strToSplit != "") :
|
||
// $strToSplit = ereg_replace ($delimiter, "-,-", $strToSplit);
|
||
$strToSplit = str_replace($delimiter, "-,-", $strToSplit);
|
||
if (!(strpos($strToSplit, "-,-") === FALSE)) :
|
||
$tmp = spliti("-,-",$strToSplit);
|
||
else :
|
||
$tmp = array($strToSplit);
|
||
endif;
|
||
$lenTmp = count($tmp);
|
||
for ($i = 0; $i < $lenTmp; $i++) {
|
||
$pos = strpos($tmp[$i], $delimiter2);
|
||
if (!($pos === FALSE)) :
|
||
// $tmp2 = spliti($delimiter2,$tmp[$i]);
|
||
// if ($tmp2[1] != "") :
|
||
// $retArray[$tmp2[0]] = $tmp2[1];
|
||
// endif;
|
||
$retArray[substr($tmp[$i],0,$pos)] = substr($tmp[$i],($pos + 1));
|
||
endif;
|
||
}
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
// Gets a string from a given associative array (key <-> value)
|
||
// E.g.: "SID=1099|CR_VHT_ID=3|JB_VHT_ID=2|LOST_RANKING=YES..." => x(SID)=1099, x(CR_VHT_ID) = 3, ...
|
||
function getStringFromKeyValueArray($arrToImplode, $delimiter = "|", $delimiter2 = "=") {
|
||
$retString = "";
|
||
if (is_array($arrToImplode)) :
|
||
$arrToImplodeKeys = array_keys($arrToImplode);
|
||
$arrToImplodeKeysLen = count($arrToImplodeKeys);
|
||
for ($i = 0; $i < $arrToImplodeKeysLen; $i++) {
|
||
if ($retString != "") : $retString .= $delimiter; endif;
|
||
$retString .= $arrToImplodeKeys[$i] . $delimiter2 . $arrToImplode[$arrToImplodeKeys[$i]];
|
||
}
|
||
endif;
|
||
return $retString;
|
||
}
|
||
|
||
// Remove item from (string) list (e.g. item "832459" will be removed from "308879|832459|830420|311009|308890|308892")
|
||
function removeItemStringList ($listString, $itemToRemove, $delimiter = "|") {
|
||
$retString = $listString;
|
||
if ($listString != "" && $itemToRemove != "") :
|
||
$listString = str_replace($delimiter, "-,-", $listString);
|
||
if (!(strpos($listString, "-,-") === FALSE)) :
|
||
$tmpArr = explode("-,-",$listString);
|
||
else :
|
||
$tmpArr = array($listString);
|
||
endif;
|
||
$itemKey = array_search($itemToRemove, $tmpArr);
|
||
if (!($itemKey === FALSE)) :
|
||
array_splice($tmpArr, $itemKey, 1);
|
||
$retString = implode("|", $tmpArr);
|
||
endif;
|
||
endif;
|
||
return $retString;
|
||
}
|
||
|
||
// Encryption
|
||
// Takes the parameter "$value" and returns the encrypted value
|
||
// See also corresponding function "dc" for decryption of the encrypted value
|
||
function ec($value = "") {
|
||
global $eca, $randomCryptionNumber, $hq_id;
|
||
if (defined('HTTP_VARS_SEC_STATE')) : $httpVarsSecState = HTTP_VARS_SEC_STATE; else : $httpVarsSecState = getParameterValue("0", "HTTP_VARS_SEC_STATE", $hq_id); endif;
|
||
if (defined('HTTP_VARS_SEC_SEQ')) : $httpVarsSecSeq = HTTP_VARS_SEC_SEQ; else : $httpVarsSecSeq = getParameterValue("0", "HTTP_VARS_SEC_SEQ", $hq_id); endif;
|
||
if ($httpVarsSecState == "1" && $value != "") :
|
||
// Encrypt the value
|
||
if (is_numeric($value)) :
|
||
// array "$eca" defined in "glob_defs.inc.php"
|
||
$value = (((((((((int) $value + (int) $randomCryptionNumber + (int) $eca[0]) * 2) + (int) $eca[1]) * 2) + (int) $eca[2]) * 2) + (int) $eca[3]) * 2) + (int) $eca[4];
|
||
else :
|
||
$value = urlencode($value);
|
||
endif;
|
||
|
||
// Set identificator-box
|
||
$value = $httpVarsSecSeq . $value . $httpVarsSecSeq;
|
||
endif;
|
||
return $value;
|
||
}
|
||
|
||
// Decryption
|
||
// Takes the parameter "$value" and returns the decrypted, original value
|
||
// See also corresponding function "ec" for encryption of the original value
|
||
function dc($value = "") {
|
||
global $eca, $randomCryptionNumber, $hq_id;
|
||
if (defined('HTTP_VARS_SEC_STATE')) : $httpVarsSecState = HTTP_VARS_SEC_STATE; else : $httpVarsSecState = getParameterValue("0", "HTTP_VARS_SEC_STATE", $hq_id); endif;
|
||
if (defined('HTTP_VARS_SEC_SEQ')) : $httpVarsSecSeq = HTTP_VARS_SEC_SEQ; else : $httpVarsSecSeq = getParameterValue("0", "HTTP_VARS_SEC_SEQ", $hq_id); endif;
|
||
$len = strlen($httpVarsSecSeq);
|
||
if (($httpVarsSecState == "1") && $value != "" && (substr(strval($value), 0, $len) == $httpVarsSecSeq) && (substr(strval($value), -$len) == $httpVarsSecSeq)) :
|
||
// Extract value from identificator-box
|
||
$value = substr(strval($value), strlen($httpVarsSecSeq), -strlen($httpVarsSecSeq));
|
||
|
||
// Decrypt the encrypted value
|
||
if (is_numeric($value)) :
|
||
$value = (((((((((int) $value - (int) $eca[4]) / 2) - (int) $eca[3]) / 2) - (int) $eca[2]) / 2) - (int) $eca[1]) / 2) - (int) $eca[0] - (int) $randomCryptionNumber;
|
||
else :
|
||
$value = urldecode($value);
|
||
endif;
|
||
endif;
|
||
return $value;
|
||
}
|
||
|
||
// Clears all parameters (sets to "") specified in array "params" containing the names of the parameters
|
||
function clearParameters($params)
|
||
{
|
||
foreach ($params as $par) {
|
||
global $$par;
|
||
$$par = "";
|
||
}
|
||
}
|
||
|
||
// Generate (zipped) string for logging
|
||
// $valArray : Array of values to be imploded by $delimiter
|
||
// $delimiter : Delimiter to seperate values for "implode()"
|
||
// $compressMode : "0" (default) = No compression, "1" = use "bzcompress()"
|
||
function makeLogString($valArray, $delimiter = ";", $compressMode = "0") {
|
||
$retString = "";
|
||
$valArrayLen = count($valArray);
|
||
if ($valArrayLen > 0) :
|
||
$retString = implode($delimiter, $valArray);
|
||
if ($compressMode == "1") :
|
||
$retString = bzcompress($retString, 9);
|
||
endif;
|
||
endif;
|
||
return $retString;
|
||
}
|
||
|
||
// Generates a random password with a length given in parameter $length
|
||
function makeRandomPassword($length = 8) {
|
||
if (!is_numeric($length) || $length == "") : $length = 8; endif;
|
||
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
|
||
srand((double)microtime()*1000000);
|
||
$i = 0;
|
||
while ($i <= $length) {
|
||
$num = rand() % 33;
|
||
$tmp = substr($salt, $num, 1);
|
||
$pass = $pass . $tmp;
|
||
$i++;
|
||
}
|
||
return $pass;
|
||
}
|
||
|
||
// Generates an concatenation of some MD5 hash values
|
||
function makeMD5Hash ($value_1, $value_2, $value_3) {
|
||
$tmpRand = rand(0,30000);
|
||
$tmpHash = md5($tmpRand) . md5($value_1) . md5($value_2) . md5($value_3);
|
||
return $tmpHash;
|
||
}
|
||
|
||
// Access-control according to the calling client-ip.
|
||
// Protection for denial-of-service-attacks
|
||
// It only should be called if name and/or password are/is wrong
|
||
function checkClientLoginTrials($mode = "0") {
|
||
global $db, $PHP_SELF, $_SERVER;
|
||
|
||
// Get the IP of the current client calling the page
|
||
// $currentClientIP = trim($_SERVER['HTTP_X_FORWARDED_FOR']);
|
||
$currentClientIP = mcArrTrim($_SERVER, "HTTP_X_FORWARDED_FOR");
|
||
if ($currentClientIP == "") :
|
||
// $currentClientIP = trim($_SERVER['REMOTE_ADDR']);
|
||
$currentClientIP = mcArrTrim($_SERVER, "REMOTE_ADDR");
|
||
endif;
|
||
|
||
// Check for existence in positive-/negative-list (ipsecurity_special)
|
||
$ipSecAccess = getFieldValueFromId("ipsecurity_special","ipsecs_ip",$currentClientIP,"ipsecs_access");
|
||
|
||
if ($ipSecAccess == "") :
|
||
|
||
// Check for existance in ipsecurity
|
||
$sqlquery = "SELECT ipsec.ipsec_ip, ipsec.ipsec_failedtrials, ipsec.ipsec_lasttrial_date"
|
||
. " FROM ipsecurity AS ipsec"
|
||
. " WHERE ipsec.ipsec_ip = '$currentClientIP'";
|
||
|
||
$result = $db->dbQ($sqlquery);
|
||
$ipsec_failedtrials = "0";
|
||
$ipsec_lasttrial_date = "";
|
||
while ($row = $result->fetch_assoc()):
|
||
$ipsec_ip = $row["ipsec_ip"];
|
||
$ipsec_failedtrials = $row["ipsec_failedtrials"];
|
||
$ipsec_lasttrial_date = $row["ipsec_lasttrial_date"];
|
||
endwhile;
|
||
$result->free();
|
||
|
||
if ($ipsec_lasttrial_date != "" && getDateTime("3") > $ipsec_lasttrial_date) :
|
||
$ipsec_failedtrials = "0";
|
||
endif;
|
||
|
||
if ($mode != "0") :
|
||
return array($currentClientIP,$ipsec_failedtrials,$ipsec_lasttrial_date);
|
||
else :
|
||
return $ipsec_failedtrials;
|
||
endif;
|
||
|
||
elseif($ipSecAccess == "0") :
|
||
|
||
$constMaxLoginTrials = getParameterValue("0", "MAXIMUM_LOGIN_TRIALS", "0", "0");
|
||
if ($mode != "0") :
|
||
return array("NOT OK",($constMaxLoginTrials + 1),$ipsec_lasttrial_date);
|
||
else :
|
||
return ($constMaxLoginTrials + 1);
|
||
endif;
|
||
|
||
else :
|
||
if ($mode != "0") :
|
||
return array("OK","0",$ipsec_lasttrial_date);
|
||
else :
|
||
return "0";
|
||
endif;
|
||
endif;
|
||
}
|
||
|
||
// Access-control according to the calling client-ip.
|
||
// Protection for denial-of-service-attacks
|
||
// It only should be called if name and/or password are/is wrong
|
||
// Returns therefore at least the value "1" or higher for the failed trials
|
||
// See function "checkClientLoginTrials()"
|
||
function updateClientLoginTrials() {
|
||
global $db, $PHP_SELF, $_SERVER;
|
||
|
||
$ipsec = checkClientLoginTrials("1");
|
||
$ipsec_ip = $ipsec[0];
|
||
$ipsec_failedtrials = $ipsec[1];
|
||
$ipsec_lasttrial_date = $ipsec[2];
|
||
|
||
// Looking for entry-data
|
||
if ($ipsec_ip != "OK" && $ipsec_ip != "NOT OK") : // Positive and negative list
|
||
if ($ipsec_failedtrials != "" && $ipsec_lasttrial_date != "") :
|
||
if (getDateTime("3") > $ipsec_lasttrial_date) :
|
||
// First failed trial of the day! It is ok! Update the existing entry
|
||
updateStmt("ipsecurity","ipsec_ip",$ipsec_ip,array("ipsec_failedtrials","1","ipsec_lasttrial_date",getDateTime("3")));
|
||
else :
|
||
// At least one failed trial of the day! Increment "$ipsec_failedtrials"
|
||
$ipsec_failedtrials++;
|
||
updateStmt("ipsecurity","ipsec_ip",$ipsec_ip,array("ipsec_failedtrials",$ipsec_failedtrials));
|
||
endif;
|
||
else :
|
||
// No entry found! Insert new entry with the current client-ip.
|
||
$defaultFields = array("ipsec_ip",$ipsec_ip,"ipsec_failedtrials","1","ipsec_lasttrial_date",getDateTime("3"));
|
||
insertStmt("ipsecurity",$defaultFields);
|
||
endif;
|
||
endif;
|
||
|
||
return $ipsec_failedtrials;
|
||
}
|
||
|
||
// Gets a list of log entries (default login)
|
||
function getListOfLogEntries($logoIdArray = array(), $datetimeOffsetArray = array(0,0,0,0,-4,0), $dbFieldsArray = array(), $empId = "", $orderByClause = "", $dbConnection = "") {
|
||
global $db, $PHP_SELF;
|
||
if (!is_object($dbConnection) || $dbConnection == "") : $dbConnection = $db; endif;
|
||
$retArray = array();
|
||
if (count($logoIdArray) > 0) :
|
||
$whereClause = "WHERE logo_id IN (" . implode(",", $logoIdArray) . ")";
|
||
$logCreatetime = getDateTime("datetime_plus_offset", $datetimeOffsetArray, "Y-m-d H:i:s");
|
||
if ($logCreatetime != "") :
|
||
$whereClause .= " AND log_createtime >= '" . $logCreatetime . "'";
|
||
endif;
|
||
if ($empId != "" && is_numeric($empId)) :
|
||
$usrId = getFieldValueFromId("employee","emp_id",$empId,"usr_id");
|
||
$whereClause .= " AND usr_id = '" . $usrId . "'";
|
||
endif;
|
||
if (count($dbFieldsArray) == 0) :
|
||
$dbFieldsArray = array("log_createtime", "hq_id", "jb_id", "usr_id", "cr_id", "cr_sid", "cs_id", "at_id", "emp_id", "logo_description");
|
||
endif;
|
||
if ($orderByClause != "") : $orderByClause = "ORDER BY " . $orderByClause; endif;
|
||
$sqlquery = "SELECT " . implode(",", $dbFieldsArray) . " FROM phoenix_log.log " . $whereClause . " " . $orderByClause;
|
||
$result = $dbConnection->dbQ($sqlquery);
|
||
$dbFieldsArrayLen = count($dbFieldsArray);
|
||
while ($row = $result->fetch_assoc()):
|
||
$tmpArray = array();
|
||
for ($i = 0; $i < $dbFieldsArrayLen; $i++) :
|
||
$tmpArray[] = $row[$dbFieldsArray[$i]];
|
||
endfor;
|
||
$retArray[] = $tmpArray;
|
||
endwhile;
|
||
$result->free();
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
// Gets special user types from parameter to match the user logged in
|
||
function getDatatransferSpecialUserData($currUserType) {
|
||
$retArray = array();
|
||
$userTypesSpecial = getParameterValue("0", "DATATRANSFER_USERTYPE_SPECIAL", "0");
|
||
if ($userTypesSpecial != "") :
|
||
$userTypesSpecial = str_replace("|", "-,-", $userTypesSpecial);
|
||
if (!(strpos($userTypesSpecial, "-,-") === FALSE)) :
|
||
$tmp = spliti("-,-",$userTypesSpecial);
|
||
else :
|
||
$tmp = array($userTypesSpecial);
|
||
endif;
|
||
$lenTmp = count($tmp);
|
||
// Iterate special users defined in table "parameter" until match with current user type logged in
|
||
for ($i = 0; $i < $lenTmp; $i++) :
|
||
$userTypesSpecialArray = spliti(",",$tmp[$i]); // e.g. $userTypesSpecialArray = array("101","107","LYRECO","CS","34705","90b1a8efc903576bbb2d6e2a79b00a5e/E")
|
||
if ($userTypesSpecialArray[0] != "" && $userTypesSpecialArray[1] != "" && $userTypesSpecialArray[2] != "" && $userTypesSpecialArray[3] != "" && $userTypesSpecialArray[4] != "" && $userTypesSpecialArray[5] != "") :
|
||
if ($currUserType == $userTypesSpecialArray[0]) :
|
||
$retArray = array($userTypesSpecialArray[0],$userTypesSpecialArray[1],$userTypesSpecialArray[2],$userTypesSpecialArray[3],$userTypesSpecialArray[4],$userTypesSpecialArray[5]);
|
||
break;
|
||
endif;
|
||
endif;
|
||
$userTypesSpecialArray = array(); // Init
|
||
endfor;
|
||
endif;
|
||
return $retArray;
|
||
};
|
||
|
||
// Check validity of an email address
|
||
function checkEmailFormat($email = "") {
|
||
$retBool = TRUE;
|
||
|
||
if (!(strpos($email, ",") === FALSE)) :
|
||
$tmp = spliti(",",$email);
|
||
else :
|
||
$tmp = array($email);
|
||
endif;
|
||
|
||
$tmpLen = count($tmp);
|
||
for ($i = 0; $i < $tmpLen; $i++) :
|
||
if (!ereg("^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$", $tmp[$i])) :
|
||
$retBool = FALSE;
|
||
endif;
|
||
// if (!ereg("^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $tmp[$i])) :
|
||
// $retBool = FALSE;
|
||
// endif;
|
||
endfor;
|
||
return $retBool;
|
||
}
|
||
|
||
// Parses a (mail)text to substitude "<postparser>"-content with object based data
|
||
function postParseMailtext ($textToParse, $objType, $objId, $moIdRefDB = "") {
|
||
global $dbname, $dblogin, $dbpassword;
|
||
$textToParse = trim($textToParse);
|
||
if ($moIdRefDB == "") :
|
||
$moIdRefDB = getParameterValue("0", "GLOBAL_UNIQUE_DB_INSTANCE_NO", "0", "0");
|
||
endif;
|
||
if ($textToParse != "" && $objType != "" && $objId != "" && $moIdRefDB != "" && is_numeric($moIdRefDB)) :
|
||
// Iterate ALL occurrences of "<postparser>...</postparser>"
|
||
while (!(strpos($textToParse, "<postparser>") === FALSE)) {
|
||
$beginTagPosBegin = strpos($textToParse, "<postparser>");
|
||
$beginTagPosEnd = $beginTagPosBegin + 12;
|
||
$endTagPosBegin = strpos($textToParse, "</postparser>");
|
||
$endTagPosEnd = $endTagPosBegin + 13;
|
||
if ($beginTagPosEnd < $endTagPosBegin) :
|
||
$tagContent = substr($textToParse, $beginTagPosEnd, $endTagPosBegin - $beginTagPosEnd);
|
||
if ($tagContent != "") :
|
||
// Special treatment
|
||
if ($tagContent == "HASH") :
|
||
// Get database instance connection data of metaobject
|
||
$constExtDbInst = getExternalMetaDbInst();
|
||
$db_conn = getDbConnectionSpecial($constExtDbInst, $dbname, $dblogin, $dbpassword);
|
||
$tagContent = $db_conn->getOne("SELECT mo.mo_hash FROM meta_object.metaobject AS mo WHERE mo.mo_obj_type = '" . $objType . "' AND mo_id_ref_db = '" . $moIdRefDB . "' AND mo.mo_obj_id = '" . $objId . "'");
|
||
$tagContent = trim($tagContent);
|
||
if ($tagContent == "") :
|
||
return "ERR";
|
||
endif;
|
||
endif;
|
||
endif;
|
||
// Substitute text fragment
|
||
$textToParse = substr_replace($textToParse, $tagContent, $beginTagPosBegin, $endTagPosEnd - $beginTagPosBegin);
|
||
endif;
|
||
}
|
||
endif;
|
||
return $textToParse;
|
||
}
|
||
|
||
// Splits a text/string for e.g. printer output
|
||
function splitText($text, $outputMode = "0", $numOfCharsForSplit = 70) {
|
||
$retArray = array();
|
||
$retText = "";
|
||
$delimiter = "|";
|
||
if ($text != ""):
|
||
|
||
$text = str_replace("\r\n", $delimiter, $text);
|
||
// $text = str_replace("\n\r", $delimiter, $text);
|
||
// $text = str_replace("\n", $delimiter, $text);
|
||
// $text = str_replace("\r", $delimiter, $text);
|
||
|
||
// Iterate ALL occurrences of "|"
|
||
while ($text != "") :
|
||
$line = substr($text, 0, $numOfCharsForSplit);
|
||
$tmpSign = substr($text, $numOfCharsForSplit, 1); // Check for following sign also is the delimiter
|
||
$text = substr($text, $numOfCharsForSplit);
|
||
// if (substr($text, 0, 1) == "|"): $text = substr($text, 1); endif;
|
||
if (substr($text, 0, 1) == "|" && $tmpSign == "|"): $text = substr($text, 1); endif;
|
||
$tmpPos = strpos($line, "|");
|
||
if (!($tmpPos === false)) :
|
||
$lineLeft = substr($line, 0, $tmpPos);
|
||
$lineRight = substr($line, ($tmpPos + 1));
|
||
|
||
$line = $lineLeft;
|
||
$text = $lineRight . $text;
|
||
endif;
|
||
|
||
$retArray[] = $line;
|
||
if ($outputMode == "1") :
|
||
$retText .= $line . "<br>";
|
||
endif;
|
||
endwhile;
|
||
|
||
endif;
|
||
if ($outputMode == "1") :
|
||
return $retText;
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
|
||
// Special version of "str_replace":
|
||
// Only each n. element will be changed. The "$needle" will be replaced by "$replaceString"
|
||
function my_str_replace ($haystack, $needle = ",", $replaceString = ",", $numOfElement = "1") {
|
||
$retString = "";
|
||
$tmpArray = spliti ($needle, $haystack);
|
||
$tmpArrayLen = count($tmpArray);
|
||
$j = 0;
|
||
$retString .= $tmpArray[0];
|
||
for ($i = 1; $i < $tmpArrayLen; $i++) :
|
||
$j++;
|
||
if ($j == $numOfElement) :
|
||
$retString .= $replaceString . $tmpArray[$i];
|
||
$j = 0;
|
||
else :
|
||
$retString .= $needle . $tmpArray[$i];
|
||
endif;
|
||
endfor;
|
||
return $retString;
|
||
}
|
||
|
||
|
||
// Validates a city and a zipcode
|
||
function checkCityZipcode($zipcode, $city, $street, $mode = "0") {
|
||
global $db, $PHP_SELF;
|
||
|
||
$zipcode = trim($zipcode);
|
||
$city = trim($city);
|
||
$street = trim($street);
|
||
|
||
// ***************************************
|
||
// * Format street for a embraced search *
|
||
// ***************************************
|
||
|
||
// Case-insensitivity (ÄÖÜäöü do not make problems because they are not changed)
|
||
// Remember the fact SQL-SELECT-LIKE-Search is case-insensitive, therefore it´s ok!
|
||
$streetToSearch = strtolower($street);
|
||
|
||
// Remove several combinations of spellings with "." as last character (e.g. "str.", "w.")
|
||
// It´s necessary to check WITH ".", because of e.g. "Ferienpark Haus W" and "Rosenw." (= "Rosenweg")
|
||
// $ignoreSuffixesArray = array("w.");
|
||
// $ignoreSuffixesArrayLen = count($ignoreSuffixesArray);
|
||
// for ($i = 0; $i < $ignoreSuffixesArrayLen; $i++) :
|
||
// $elemLen = strlen($ignoreSuffixesArray[$i]);
|
||
// if (substr($streetToSearch, -($elemLen)) == $ignoreSuffixesArray[$i]) : $streetToSearch = substr($streetToSearch, 0, -($elemLen)); endif;
|
||
// endfor;
|
||
|
||
// Remove last character if it is "." (like "...str.", "... Str.", etc.)
|
||
if (substr($streetToSearch, -1) == ".") : $streetToSearch = substr($streetToSearch, 0, -1); endif;
|
||
|
||
// Remove several combinations of spellings
|
||
$ignoreSuffixesArray = array(" strasse","strasse"," straße","straße"," str","str"," platz","platz"," pl"," weg","weg",
|
||
" wiese","wiese"," gasse","gasse"," chaussee","chaussee"," ch"," twiete","twiete",
|
||
" wieke","wieke"," feld","feld"," kamp","kamp"," allee","allee"," schaft","schaft",
|
||
" hof","hof"," teich","teich"," bach","bach"," loch","loch"," ring","ring");
|
||
$ignoreSuffixesArrayLen = count($ignoreSuffixesArray);
|
||
for ($i = 0; $i < $ignoreSuffixesArrayLen; $i++) :
|
||
$elemLen = strlen($ignoreSuffixesArray[$i]);
|
||
if (substr($streetToSearch, -($elemLen)) == $ignoreSuffixesArray[$i]) : $streetToSearch = substr($streetToSearch, 0, -($elemLen)); endif;
|
||
endfor;
|
||
|
||
// Check length of the string "$streetToSearch"
|
||
// (because of the problem that a street name can be "Chausseestr." ...)
|
||
if (strlen($streetToSearch) == "") :
|
||
$streetToSearch = strtolower($street);
|
||
// Remove last character if "." again
|
||
if (substr($streetToSearch, -1) == ".") : $streetToSearch = substr($streetToSearch, 0, -1); endif;
|
||
endif;
|
||
|
||
$matchedCount = 0;
|
||
$addresses = array();
|
||
|
||
if ($city != "" && $zipcode != ""):
|
||
|
||
$sqlquery = "SELECT st.st_zipcode, st.st_city, st.st_street, st_district, st_no_from, st_no_to"
|
||
. " FROM phoenix_special.street AS st"
|
||
. " WHERE st.st_zipcode = '" . $zipcode . "'"
|
||
. " AND st.st_city LIKE '" . $city . "%'"
|
||
. " AND st.st_street LIKE '" . $streetToSearch . "%'"
|
||
. " ORDER BY st.st_zipcode";
|
||
|
||
$result = $db->dbQ($sqlquery);
|
||
while ($row = $result->fetch_assoc()):
|
||
$matchedCount++;
|
||
$addresses["zipcode"][$matchedCount] = $row["st_zipcode"];
|
||
$addresses["city"][$matchedCount] = $row["st_city"];
|
||
$addresses["street"][$matchedCount] = $row["st_street"];
|
||
$addresses["st_district"][$matchedCount] = $row["st_district"];
|
||
$addresses["st_no_from"][$matchedCount] = $row["st_no_from"];
|
||
$addresses["st_no_to"][$matchedCount] = $row["st_no_to"];
|
||
endwhile;
|
||
$result->free();
|
||
endif;
|
||
|
||
if (AD_STATUS == "0") : $matchedCount = 1; endif;
|
||
|
||
switch($mode) {
|
||
case "0" :
|
||
return array($matchedCount,$addresses); break;
|
||
case "1" :
|
||
return $matchedCount; break;
|
||
case "2" :
|
||
return $addresses; break;
|
||
default :
|
||
return array($matchedCount,$addresses);
|
||
};
|
||
}
|
||
|
||
function getValsFromDate2($dateVal)
|
||
{
|
||
// "2003-01-16 18:40:23"
|
||
return(array(
|
||
(is_int(substr($dateVal, 0, 4)) ? substr($dateVal, 0, 4) : 0),
|
||
(is_int(substr($dateVal, 5, 2)) ? substr($dateVal, 5, 2) : 0),
|
||
(is_int(substr($dateVal, 8, 2)) ? substr($dateVal, 8, 2) : 0),
|
||
(is_int(substr($dateVal, 11, 2)) ? substr($dateVal, 11, 2) : 0),
|
||
(is_int(substr($dateVal, 14, 2)) ? substr($dateVal, 14, 2) : 0),
|
||
(is_int(substr($dateVal, 17, 2)) ? substr($dateVal, 17, 2) : 0)
|
||
));
|
||
}
|
||
|
||
//function crIsOccupied($cr_id)
|
||
//{
|
||
// global $db;
|
||
//
|
||
//// $hq_id = $db->getOne("SELECT hq_id FROM courier WHERE cr_id = '" . $cr_id . "'");
|
||
//// $sqlQuery =
|
||
//// "SELECT jb_id, jb_ordertime FROM job WHERE cr_id_order = '" . $cr_id . "' AND (jb_status = 0 OR jb_status = 1) ORDER BY jb_id ASC";
|
||
//
|
||
// $currentTime = getDateTime("0");
|
||
// $sqlQuery = "SELECT jb.jb_id"
|
||
// . " FROM courier AS cr, job AS jb, tour AS tr, address AS ad LEFT JOIN serviceplz AS srvp ON ad.ad_zipcode = srvp.srvp_plz"
|
||
// . " LEFT JOIN serviceplztraveltime AS srvpt ON srvp.srvp_id = srvpt.srvp_id AND srvpt.hq_id = jb.hq_id"
|
||
// . " WHERE jb.cr_id_order = '" . $cr_id . "' AND"
|
||
// . " (jb_status = 0 OR jb_status = 1) AND"
|
||
// . " jb.hq_id = cr.hq_id AND"
|
||
// . " (DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime,30) MINUTE) <= '" . $currentTime . "') AND"
|
||
// . " jb.jb_id = tr.jb_id AND"
|
||
// . " tr.tr_sort = 1 AND"
|
||
// . " tr.ad_id = ad.ad_id"
|
||
// . " LIMIT 0,1";
|
||
// $res = $db->query($sqlQuery);
|
||
// if ($db->connect_errno) die ("$PHP_SELF: <br>$sqlQuery<br>" . $db->connect_error);
|
||
// $is_occupied = false;
|
||
// while ($row = $res->fetch_assoc()):
|
||
// // wenn mind. ein Job gefunden wurde, dann ist der Kurier occupied
|
||
// $res->free();
|
||
// return true;
|
||
// endwhile;
|
||
// $res->free();
|
||
// return false;
|
||
//}
|
||
|
||
function crIsOccupied($cr_id, $jb_id = "")
|
||
{
|
||
global $db, $db2;
|
||
|
||
$theDb = $db;
|
||
if (isset($db2))
|
||
$theDb = $db2;
|
||
|
||
$currentTime = getDateTime("0");
|
||
|
||
$whereClause1 = "(DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime,30) MINUTE) <= '" . $currentTime . "') AND ";
|
||
if ($jb_id != "") :
|
||
// $jbOrdertime = $db2->getOne("SELECT jb_ordertime FROM job WHERE jb_id = '" . $jb_id . "'");
|
||
$jbOrdertime = getOneStmt("SELECT jb_ordertime FROM job WHERE jb_id = '" . $jb_id . "'", "jb_ordertime");
|
||
if ($jbOrdertime != "") :
|
||
$whereClause1 = "( (DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime,30) MINUTE) <= '" . $currentTime . "') OR " .
|
||
//Konkurrenz-Auftrag ist in Bezug auf den gegenwärtigen Zeitpunkt schon innerhalb der Vorlaufzeit -> der Fahrer ist jetzt mit diesem Auftrag belegt
|
||
" ((DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime,30) MINUTE) <= '" . $jbOrdertime . "') AND" .
|
||
" jb.jb_ordertime >= '" . $jbOrdertime . "') ) AND";
|
||
//Auftragszeit des Konkurrenz-Auftrags liegt in der Vorlaufzeit des zu vermittelnden Auftrags -> Auftrag kann nicht an den Fahrer vermittelt werden
|
||
endif;
|
||
endif;
|
||
/*
|
||
$sqlQuery = "SELECT jb.jb_id"
|
||
. " FROM courier AS cr, job AS jb, tour AS tr, address AS ad LEFT JOIN serviceplz AS srvp ON ad.ad_zipcode = srvp.srvp_plz"
|
||
. " LEFT JOIN serviceplztraveltime AS srvpt ON srvp.srvp_id = srvpt.srvp_id AND srvpt.hq_id = jb.hq_id"
|
||
. " WHERE jb.cr_id_order = '" . $cr_id . "' AND"
|
||
. " (jb_status = 0 OR jb_status = 1) AND"
|
||
. " jb.hq_id = cr.hq_id AND"
|
||
. " " . $whereClause1 . " "
|
||
. " jb.jb_id = tr.jb_id AND"
|
||
. " tr.tr_sort = 1 AND"
|
||
. " tr.ad_id = ad.ad_id"
|
||
. " LIMIT 0,1";
|
||
|
||
$sqlQuery = "SELECT jb.jb_id"
|
||
. " FROM courier AS cr, job AS jb, tour AS tr, address AS ad LEFT JOIN serviceplz AS srvp ON ad.ad_zipcode = srvp.srvp_plz"
|
||
. " LEFT JOIN serviceplztraveltime AS srvpt ON srvp.srvp_id = srvpt.srvp_id"
|
||
. " WHERE jb.cr_id_order = '" . $cr_id . "' AND"
|
||
. " (jb_status = 0 OR jb_status = 1) AND"
|
||
. " jb.hq_id = cr.hq_id AND"
|
||
. " " . $whereClause1 . " "
|
||
. " jb.jb_id = tr.jb_id AND"
|
||
. " tr.tr_sort = 1 AND"
|
||
. " tr.ad_id = ad.ad_id AND"
|
||
. " (srvpt.hq_id = jb.hq_id OR srvpt.hq_id IS NULL)"
|
||
. " LIMIT 0,1";
|
||
*/
|
||
$sqlQuery = "SELECT jb.jb_id"
|
||
. " FROM courier AS cr, job AS jb, tour AS tr, address AS ad LEFT JOIN serviceplz AS srvp ON ad.ad_zipcode = srvp.srvp_plz"
|
||
. " LEFT JOIN serviceplztraveltime AS srvpt ON srvp.srvp_id = srvpt.srvp_id"
|
||
. " WHERE cr.cr_id = '" . $cr_id . "' AND"
|
||
. " jb.cr_id_order = cr.cr_id AND"
|
||
. " (jb_status = 0 OR jb_status = 1) AND"
|
||
. " " . $whereClause1 . " "
|
||
. " jb.jb_id = tr.jb_id AND"
|
||
. " tr.tr_sort = 1 AND"
|
||
. " tr.ad_id = ad.ad_id AND"
|
||
. " (srvpt.hq_id = jb.hq_id OR srvpt.hq_id IS NULL)";
|
||
|
||
$res = $db2->query($sqlQuery);
|
||
if ($db2->connect_errno) die ("$PHP_SELF: <br>$sqlQuery<br>" . $db2->connect_error);
|
||
$is_occupied = false;
|
||
while ($row = $res->fetch_assoc()):
|
||
// wenn mind. ein Job gefunden wurde, dann ist der Kurier occupied
|
||
$res->free();
|
||
$cmd = "php ../tools/get_job_duration.php " . $cr_id . " " . $jb_id . " true >> ../log/get_job_duration.stdout+err 2>&1 &";
|
||
exec($cmd);
|
||
return true;
|
||
endwhile;
|
||
$res->free();
|
||
$cmd = "php ../tools/get_job_duration.php " . $cr_id . " " . $jb_id . " false >> ../log/get_job_duration.stdout+err 2>&1 &";
|
||
exec($cmd);
|
||
return false;
|
||
}
|
||
|
||
//function checkCrIsOccupied($row)
|
||
//{
|
||
// global $db, $hq_id;
|
||
//
|
||
////echo "'" . crIsOccupied(944) . "'";
|
||
////die (crIsOccupied(973));
|
||
//
|
||
// $currentTime = getDateTime("0");
|
||
// $sqlquery = "SELECT jb.jb_id"
|
||
// . " FROM job AS jb, tour AS tr, address AS ad LEFT JOIN serviceplz AS srvp ON ad.ad_zipcode = srvp.srvp_plz"
|
||
// . " LEFT JOIN serviceplztraveltime AS srvpt ON srvp.srvp_id = srvpt.srvp_id AND srvpt.hq_id = jb.hq_id"
|
||
// . " WHERE jb.jb_id = '" . $row["jb_id"] . "' AND"
|
||
// . " jb.hq_id = '" . $hq_id . "' AND"
|
||
// . " (DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime," . MASK_COURIER_FREETIME_MINUTES . ") MINUTE) <= '" . $currentTime . "') AND"
|
||
// . " jb.jb_id = tr.jb_id AND"
|
||
// . " tr.tr_sort = 1 AND"
|
||
// . " tr.ad_id = ad.ad_id"
|
||
// . " LIMIT 0,1";
|
||
//
|
||
// if ($db->getOne($sqlquery) == $row["jb_id"])
|
||
// return true;
|
||
// return false;
|
||
//}
|
||
|
||
function checkCrIsOccupied($jb_id0, $jb_id1)
|
||
{
|
||
global $db, $db2;
|
||
|
||
$theDb = $db;
|
||
if (isset($db2))
|
||
$theDb = $db2;
|
||
|
||
$currentTime = getDateTime("0");
|
||
|
||
$whereClause1 = "(DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime,30) MINUTE) <= '" . $currentTime . "') AND ";
|
||
if ($jb_id1 != "") :
|
||
// $jbOrdertime = $theDb->getOne("SELECT jb_ordertime FROM job WHERE jb_id = '" . $jb_id1 . "'");
|
||
$jbOrdertime = getOneStmt("SELECT jb_ordertime FROM job WHERE jb_id = '" . $jb_id1 . "'", "jb_ordertime", $theDb);
|
||
if ($jbOrdertime != "") :
|
||
$whereClause1 = "( (DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime,30) MINUTE) <= '" . $currentTime . "') OR " .
|
||
" ((DATE_SUB(jb.jb_ordertime, INTERVAL GREATEST(srvpt.srvpt_traveltime,30) MINUTE) <= '" . $jbOrdertime . "') AND" .
|
||
" jb.jb_ordertime >= '" . $jbOrdertime . "') ) AND";
|
||
endif;
|
||
endif;
|
||
/*
|
||
$sqlquery = "SELECT jb.jb_id"
|
||
. " FROM job AS jb, tour AS tr, address AS ad LEFT JOIN serviceplz AS srvp ON ad.ad_zipcode = srvp.srvp_plz"
|
||
. " LEFT JOIN serviceplztraveltime AS srvpt ON srvp.srvp_id = srvpt.srvp_id AND srvpt.hq_id = jb.hq_id"
|
||
. " WHERE jb.jb_id = '" . $jb_id0 . "' AND"
|
||
. " " . $whereClause1 . " "
|
||
. " jb.jb_id = tr.jb_id AND"
|
||
. " tr.tr_sort = 1 AND"
|
||
. " tr.ad_id = ad.ad_id"
|
||
. " LIMIT 0,1";
|
||
*/
|
||
$sqlquery = "SELECT jb.jb_id"
|
||
. " FROM job AS jb, tour AS tr, address AS ad LEFT JOIN serviceplz AS srvp ON ad.ad_zipcode = srvp.srvp_plz"
|
||
. " LEFT JOIN serviceplztraveltime AS srvpt ON srvp.srvp_id = srvpt.srvp_id"
|
||
. " WHERE jb.jb_id = '" . $jb_id0 . "' AND"
|
||
. " " . $whereClause1 . " "
|
||
. " jb.jb_id = tr.jb_id AND"
|
||
. " tr.tr_sort = 1 AND"
|
||
. " tr.ad_id = ad.ad_id AND"
|
||
. " (srvpt.hq_id = jb.hq_id OR srvpt.hq_id IS NULL)"
|
||
. " LIMIT 0,1";
|
||
// if ($theDb->getOne($sqlquery) == $jb_id0)
|
||
if (getOneStmt($sqlquery, "jb_id", $theDb) == $jb_id0)
|
||
return true;
|
||
return false;
|
||
}
|
||
|
||
// 28.11.2022: crvh_filter does not contain "EG" und crvh_totalweight >= 2800, then foreign countries are not allowed
|
||
// 14.07.2023: correction: -"- , then going to foreign countries within the EU is not allowed
|
||
function check_third_country($jb_id, $cr_id) {
|
||
global $db2;
|
||
|
||
if ($db2->getOne("SELECT crvh_totalweight FROM couriervehicle AS crvh, courier as cr WHERE cr.cr_sid = crvh.crvh_sid AND crvh.cr_id = " . $cr_id) >= 2800
|
||
&& strpos($db2->getOne("SELECT crvh_filter FROM couriervehicle AS crvh, courier as cr WHERE cr.cr_sid = crvh.crvh_sid AND crvh.cr_id = " . $cr_id), "EG") === false):
|
||
$eu_countrycodes = getParameterValue("0", "EU_COUNTRYCODES", "0");
|
||
$sqlQuery = "SELECT DISTINCT ad_country FROM address, tour WHERE address.ad_id = tour.ad_id AND jb_id = " . $jb_id;
|
||
$res = $db2->query($sqlQuery);
|
||
if ($db2->connect_errno) reportDie ("$PHP_SELF: '$sqlQuery'" . $db->connect_error);
|
||
while ($row = $res->fetch_assoc()):
|
||
if ($row["ad_country"] != "DE" && !strpos($eu_countrycodes, $row["ad_country"]) === false):
|
||
$res->free();
|
||
return false;
|
||
endif;
|
||
endwhile;
|
||
$res->free();
|
||
endif;
|
||
return true;
|
||
}
|
||
|
||
function check_cr_agio($jb_id, $co2Only = false) {
|
||
global $db, $db2;
|
||
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: \$jb_id = $jb_id, \$co2Only = " . $co2Only);
|
||
if (trim($jb_id) == "" || !is_numeric($jb_id) || $jb_id == 0)
|
||
return;
|
||
|
||
$cmd = "php ../tools/get_job_distance.php " . $jb_id . " >> ../log/get_job_distance.stdout+err 2>&1 &";
|
||
exec($cmd);
|
||
|
||
if ($co2Only)
|
||
return;
|
||
//writeLog_("../log/check_cr_agio_", "check_cr_agio: [SELECT cscr_prov FROM customercourier, customer, costcenter, job" .
|
||
// " WHERE jb_id = " . $jb_id . " AND job.csc_id_payer = costcenter.csc_id AND costcenter.cs_id = customer.cs_id AND customer.cs_id = customercourier.cs_id AND job.cr_id = customercourier.cr_id]");
|
||
// $jb_cr_agio = $db->getOne("SELECT cscr_prov FROM customercourier, customer, costcenter, job" .
|
||
// " WHERE jb_id = " . $jb_id . " AND job.csc_id_payer = costcenter.csc_id AND costcenter.cs_id = customer.cs_id AND customer.cs_id = customercourier.cs_id AND job.cr_id = customercourier.cr_id");
|
||
$cr_id = $db->getOne("SELECT cr_id FROM job WHERE jb_id = " . $jb_id);
|
||
$cs_id = $db->getOne("SELECT cs_id FROM job, costcenter WHERE jb_id = " . $jb_id . " AND job.csc_id_payer = costcenter.csc_id");
|
||
// $cr_sid = $db->getOne("SELECT cr_sid FROM job WHERE jb_id = " . $jb_id);
|
||
// $crvh_id = getFieldValueFromClause("couriervehicle", "crvh_id", "cr_id = '" . $cr_id . "' AND crvh_sid = '" . $cr_sid . "'");
|
||
$jb_ordertime = $db->getOne("SELECT jb_ordertime FROM job WHERE jb_id = " . $jb_id);
|
||
// $jb_cr_agio = $db->getOne("SELECT srvprch.srvprch_price FROM servicepricehistory AS srvprch" .
|
||
// " WHERE srvprch.srvprch_obj_type = 'cr' AND srvprch.srvprch_obj_id = '" . $crvh_id . "' AND srvprch.srvprch_fieldname = 'cscr_prov' AND srvprch.srvprch_validfrom <= '" . $jb_ordertime . "'" .
|
||
// " ORDER BY srvprch.srvprch_validfrom DESC");
|
||
$jb_cr_agio = $db->getOne("SELECT srvprch.srvprch_price FROM servicepricehistory AS srvprch" .
|
||
" WHERE srvprch.srvprch_obj_type = 'cr' AND srvprch.srvprch_obj_id = '" . $cr_id . "' AND srvprch.srvprch_fieldname = 'cscr_prov' AND srvprch_context = '" . $cs_id . "' AND srvprch.srvprch_validfrom <= '" . $jb_ordertime . "'" .
|
||
" ORDER BY srvprch.srvprch_validfrom DESC");
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: [SELECT srvprch.srvprch_price FROM servicepricehistory AS srvprch" .
|
||
" WHERE srvprch.srvprch_obj_type = 'cr' AND srvprch.srvprch_obj_id = '" . $cr_id . "' AND srvprch.srvprch_fieldname = 'cscr_prov' AND srvprch_context = '" . $cs_id . "' AND srvprch.srvprch_validfrom <= '" . $jb_ordertime . "'" .
|
||
" ORDER BY srvprch.srvprch_validfrom DESC]");
|
||
|
||
if ($jb_cr_agio == "")
|
||
$jb_cr_agio = 0;
|
||
//writeLog_("../log/check_cr_agio_", "check_cr_agio: [SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 7]");
|
||
$jbprc_price_agio = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 7");
|
||
if ($jbprc_price_agio == "")
|
||
$jbprc_price_agio = 0;
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: [DELETE FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 7]");
|
||
$db->query("DELETE FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 7");
|
||
$jb_cr_price_rate = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 5");
|
||
if ($jb_cr_price_rate == "")
|
||
$jb_cr_price_rate = 0;
|
||
if (is_numeric($jbprc_price_agio) && is_numeric($jb_cr_agio) && ($jbprc_price_agio > 0 || $jb_cr_agio > 0) && $jb_cr_price_rate > 0) {
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: \$jb_cr_agio = $jb_cr_agio, \$jbprc_price_agio = $jbprc_price_agio, \$jb_cr_price_rate = $jb_cr_price_rate");
|
||
if ($jb_cr_agio != 0) {
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: [INSERT INTO jobprice (jb_id, mt_sort, jbprc_price) VALUES (" . $jb_id . ", 7, " . $jb_cr_agio . ")]");
|
||
$db->query("INSERT INTO jobprice (jb_id, mt_sort, jbprc_price) VALUES (" . $jb_id . ", 7, " . $jb_cr_agio . ")");
|
||
}
|
||
$jb_cr_markup = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort IN (1,9)");
|
||
if ($jb_cr_markup == "")
|
||
$jb_cr_markup = 0;
|
||
$jb_cr_fixserviceprice = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 3");
|
||
if ($jb_cr_fixserviceprice == "")
|
||
$jb_cr_fixserviceprice = 0;
|
||
$jb_cr_serviceprice = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 4");
|
||
if ($jb_cr_serviceprice == "")
|
||
$jb_cr_serviceprice = 0;
|
||
$jb_subtotal = $db->getOne("SELECT jb_subtotalprice - jb_serviceprice FROM job WHERE jb_id = " . $jb_id);
|
||
// $jb_serviceprice = $db->getOne("SELECT jb_serviceprice FROM job WHERE jb_id = " . $jb_id);
|
||
// $jb_cr_price = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 10") - $jb_cr_serviceprice - $jb_cr_fixserviceprice;
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: \$jb_subtotal = " . $jb_subtotal . ", \$jb_cr_price_rate = " . $jb_cr_price_rate);
|
||
$jb_cr_subtotal = round($jb_subtotal * (100 - ($jb_cr_price_rate - $jb_cr_agio)) / 100, 2);
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: \$jb_cr_subtotal = " . $jb_cr_subtotal);
|
||
$jb_cr_serviceprice_rate = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 6");
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: \$jb_cr_serviceprice_rate = " . $jb_cr_serviceprice_rate);
|
||
if ($jb_cr_serviceprice_rate > 0)
|
||
$jb_cr_serviceprice = round($jb_cr_serviceprice * (100 - ($jb_cr_serviceprice - $jb_cr_agio)) / 100, 2);
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: \$jb_cr_serviceprice = " . $jb_cr_serviceprice);
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: [DELETE FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 10]");
|
||
$db->query("DELETE FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 10");
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: [INSERT INTO jobprice (jb_id, mt_sort, jbprc_price) VALUES (" . $jb_id . ", 10, " . ($jb_cr_subtotal + $jb_cr_serviceprice + $jb_cr_fixserviceprice) . ")]");
|
||
$db->query("INSERT INTO jobprice (jb_id, mt_sort, jbprc_price) VALUES (" . $jb_id . ", 10, " . ($jb_cr_subtotal + $jb_cr_serviceprice + $jb_cr_fixserviceprice) . ")");
|
||
$jb_cr_price_total = round($jb_cr_subtotal * (1 + ($jb_cr_markup / 100)), 2) + $jb_cr_serviceprice + $jb_cr_fixserviceprice;
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: [UPDATE job SET jb_cr_price = " . $jb_cr_price_total . " WHERE jb_id = " . $jb_id . "]");
|
||
$db->query("UPDATE job SET jb_cr_price = " . $jb_cr_price_total . " WHERE jb_id = " . $jb_id);
|
||
} elseif (!is_numeric($jbprc_price_agio) || !is_numeric($jb_cr_agio)) {
|
||
writeLog_("../log/check_cr_agio_", "check_cr_agio: \$jb_cr_agio = $jb_cr_agio, \$jbprc_price_agio = $jbprc_price_agio: At least one of theses values is not numeric");
|
||
}
|
||
}
|
||
|
||
function recalc_jb_price($jb_id, $jb_markup_old) {
|
||
global $db;
|
||
|
||
$jbprc_markup = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 8");
|
||
if ($jbprc_markup == "")
|
||
$jb_markup = $db->getOne("SELECT jb_markup FROM job WHERE jb_id = " . $jb_id);
|
||
$hq_id = $db->getOne("SELECT hq_id FROM job WHERE jb_id = " . $jb_id);
|
||
|
||
$sqlquery = "SELECT tr_sort, trs_srv_name, trs_price FROM tourservice WHERE jb_id = '" . $jb_id . "'";
|
||
$res = $db->query($sqlquery);
|
||
if (DB::isError($res)) {
|
||
reportDie ("$PHP_SELF: '$sqlquery' : " . $res->getMessage());
|
||
}
|
||
while ($row = $res->fetch_assoc()) {
|
||
if ($row["trs_srv_name"] != "Servicepreis" && !($row["trs_srv_name"] == "Grundpreis" && getParameterValue("0", "MASK_NO_MARKUP_ON_VEHICLE_PRICE", $hq_id) == "1")) {
|
||
writeLog_("../log/check_markup_", "UPDATE tourservice SET trs_price = " . round($row["trs_price"] / (1 + ($jb_markup_old / 100)) * (1 + ($jb_markup / 100)), 2) . " WHERE jb_id = " . $jb_id . " AND tr_sort = " . $row["tr_sort"] . " AND trs_srv_name = '" . $row["trs_srv_name"] . "' AND trs_price = '" . $row["trs_price"] . "'");
|
||
$db->query("UPDATE tourservice SET trs_price = " . round($row["trs_price"] / (1 + ($jb_markup_old / 100)) * (1 + ($jb_markup / 100)), 2) . " WHERE jb_id = " . $jb_id . " AND tr_sort = " . $row["tr_sort"] . " AND trs_srv_name = '" . $row["trs_srv_name"] . "' AND trs_price = '" . $row["trs_price"] . "'");
|
||
}
|
||
}
|
||
$res->free();
|
||
$jb_serviceprice = $db->getOne("SELECT jb_serviceprice FROM job WHERE jb_id = " . $jb_id);
|
||
$jb_subtotalprice = $db->getOne("SELECT jb_subtotalprice FROM job WHERE jb_id = " . $jb_id);
|
||
$jb_totalprice = round($jb_subtotalprice * (1 + ($jb_markup / 100)), 2) + $jb_serviceprice;
|
||
writeLog_("../log/check_markup_", "UPDATE job SET jb_totalprice = " . $jb_totalprice . " WHERE jb_id = " . $jb_id);
|
||
$db->query("UPDATE job SET jb_totalprice = " . $jb_totalprice . " WHERE jb_id = " . $jb_id);
|
||
writeLog_("../log/check_markup_", "INSERT INTO genericdatacontainer (gdc_obj_type, gdc_obj_id, gdc_gen_fieldname, gdc_content, gdc_context) VALUES ('jb', " . $jb_id . ", 'jb_invtext_dirty', '1', '" . date("Y-m-d H:i:s") . "')");
|
||
$db->query("INSERT INTO genericdatacontainer (gdc_obj_type, gdc_obj_id, gdc_gen_fieldname, gdc_content, gdc_context) VALUES ('jb', " . $jb_id . ", 'jb_invtext_dirty', '1', '" . date("Y-m-d H:i:s") . "')");
|
||
}
|
||
|
||
function recalc_jb_cr_price($jb_id) {
|
||
global $db;
|
||
|
||
$jb_cr_markup = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort IN (1, 9)");
|
||
$jbprc_price_agio = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 7");
|
||
$jb_cr_fixserviceprice = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 3");
|
||
if ($jb_cr_fixserviceprice == "")
|
||
$jb_cr_fixserviceprice = 0;
|
||
$jb_cr_serviceprice = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 4");
|
||
if ($jb_cr_serviceprice == "")
|
||
$jb_cr_serviceprice = 0;
|
||
$jb_cr_price = $db->getOne("SELECT jbprc_price FROM jobprice WHERE jb_id = " . $jb_id . " AND mt_sort = 10");
|
||
$jb_cr_price_total = round($jb_cr_price * (1 + ($jb_cr_agio / 100)) * (1 + ($jb_cr_markup / 100)), 2) + $jb_cr_serviceprice + $jb_cr_fixserviceprice;
|
||
writeLog_("../log/check_markup_", "UPDATE job SET jb_cr_price = " . $jb_cr_price_total . " WHERE jb_id = " . $jb_id);
|
||
$db->query("UPDATE job SET jb_cr_price = " . $jb_cr_price_total . " WHERE jb_id = " . $jb_id);
|
||
|
||
$tr_remark = $db->getOne("SELECT tr_remark FROM tour WHERE jb_id = " . $jb_id . " AND tr_sort = 1");
|
||
if (!(strpos($tr_remark, "[[") === false)) {
|
||
$jb_cr_priceStr = strstr($tr_remark, "[[");
|
||
$jb_cr_priceStr = substr($jb_cr_priceStr, 0, strpos($jb_cr_priceStr, "]]", 2) + 2);
|
||
if (!(strpos($jb_cr_priceStr, "Frachtverguetung:") === false)) {
|
||
$jb_cr_priceStr = strstr($jb_cr_priceStr, "Frachtverguetung:");
|
||
$jb_cr_priceStr = substr($jb_cr_priceStr, 0, strpos($jb_cr_priceStr, "EUR") + 3);
|
||
$tr_remark = str_replace($jb_cr_priceStr, "Frachtverguetung: " . str_replace(".", ",", sprintf("%01.2f", $jb_cr_price_total)) . " EUR", $tr_remark);
|
||
writeLog_("../log/check_markup_", "UPDATE tour SET tr_remark = '" . $tr_remark . "' WHERE jb_id = " . $jb_id . " AND tr_sort = 1");
|
||
$db->query("UPDATE tour SET tr_remark = '" . $tr_remark . "' WHERE jb_id = " . $jb_id . " AND tr_sort = 1");
|
||
}
|
||
}
|
||
}
|
||
|
||
function reportDie($errmsg = "undefined error", $sendmail = true)
|
||
{
|
||
global $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_COOKIE_VARS, $HTTP_ENV_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_POST_FILES;
|
||
|
||
$today = getdate();
|
||
$errReport = "\n[" . date("Y-m-d H:i:s") . "] '" . $errmsg . "'\n";
|
||
$var_dump_arr = debug_backtrace();
|
||
$errReport .= "IN FILE: '" . $var_dump_arr[0]["file"] . "', LINE: " . $var_dump_arr[0]["line"] . "\n";
|
||
|
||
$httpGVars = "";
|
||
$httpGSVars = "";
|
||
$httpPVars = "";
|
||
$httpSSVars = "";
|
||
$httpSEVars = "";
|
||
$httpCVars = "";
|
||
foreach($HTTP_GET_VARS as $key => $val) {
|
||
$httpGVars .= "$key=$val&";
|
||
getSecHttpVars("1", array($key));
|
||
$httpGSVars .= "$key=" . $$key . "&";
|
||
}
|
||
foreach($HTTP_POST_VARS as $key => $val) { $httpPVars .= "$key=$val, "; }
|
||
foreach($HTTP_SESSION_VARS as $key => $val) {
|
||
if (substr($key, 0, 4) != "SSL_")
|
||
$httpSSVars .= "$key=$val, ";
|
||
}
|
||
foreach($HTTP_SERVER_VARS as $key => $val) { $httpSEVars .= "$key=$val, "; }
|
||
foreach($HTTP_COOKIE_VARS as $key => $val) { $httpCVars .= "$key=$val, "; }
|
||
$errReport .= "HTTP_GET_VARS : [$httpGVars]\n";
|
||
$errReport .= "HTTP_GET_SECVARS : [$httpGSVars]\n";
|
||
$errReport .= "HTTP_POST_VARS : [$httpPVars]\n";
|
||
$errReport .= "HTTP_SESSION_VARS: [$httpSSVars]\n";
|
||
$errReport .= "HTTP_SERVER_VARS : [$httpSEVars]\n";
|
||
$errReport .= "HTTP_COOKIE_VARS : [$httpCVars]\n";
|
||
$fileHandle = @fopen("../log/die_" . $today['year'] . sprintf("%02d", $today['mon']) . ".log", 'a');
|
||
@fwrite($fileHandle, $errReport);
|
||
@fclose($fileHandle);
|
||
|
||
$userErrMsg = getLngt("Es ist ein unerwarteter Fehler aufgetreten.");
|
||
if($sendmail) {
|
||
$conf = prepareSendMailPear("smtp.1und1.com","admin@assecutor.de","a7=!wURsT","admin@assecutor.de","ALERT: UNEXPECTED ERROR !!!","Assecutor","admin@assecutor.de","ALERT: UNEXPECTED ERROR !!!) $errReport");
|
||
$mail_object =& Mail::factory("smtp", $conf[0]);
|
||
$mail_object->send($conf[1], $conf[2], $conf[3]);
|
||
$userErrMsg .= getLngt("Die Systemadministration wurde hierüber soeben automatisch per Email in Kenntnis gesetzt.");
|
||
} else {
|
||
$userErrMsg .= getLngt("Sollte dieses Problem fortbestehen, so wenden Sie sich bitte an Ihre Systemadministration.");
|
||
}
|
||
|
||
die("<span style=\"color:red\">" . $userErrMsg . "</span>");
|
||
}
|
||
|
||
// Get mapped vehicle type ID for zipcode matrix and area matrix
|
||
function getServiceVehicleTypeMappingId ($vhtId = "0") {
|
||
global $hq_id;
|
||
if ($vhtId == "") : $vhtId = "0"; endif;
|
||
$vhtIdMapped = $vhtId;
|
||
$parServiceVehicleTypeEnabled = getParameterValue("0", "SERVICE_VEHICLE_TYPE_ENABLED", $hq_id);
|
||
if ($parServiceVehicleTypeEnabled == "1") :
|
||
$parServiceVehicleTypeMapping = getParameterValue("0", "SERVICE_VEHICLE_TYPE_MAPPING", $hq_id);
|
||
// Array of existing vehicle type mappings
|
||
$existingVhtArray = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'vehicletype'", "", "mt_sort", "");
|
||
if ($parServiceVehicleTypeMapping != "") :
|
||
// Array of mapped vehicle types
|
||
$vhtMappingArray = getKeyValueArrayFromString($parServiceVehicleTypeMapping); // E.g.: 1=2|3=2|4=2 <=> Kombi=PKW|Kastenwagen=PKW
|
||
$vhtIdMapped = $vhtMappingArray[$vhtId];
|
||
if ($vhtId != "0" && $vhtIdMapped != "" && is_numeric($vhtIdMapped)) :
|
||
// 2nd check for mapping is an existing vehicle type
|
||
$j = array_search($vhtIdMapped, $existingVhtArray);
|
||
if ($j === FALSE) :
|
||
$vhtIdMapped = $vhtId;
|
||
endif;
|
||
else :
|
||
$vhtIdMapped = $vhtId;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
return $vhtIdMapped;
|
||
}
|
||
|
||
// Check for employee having multiple access regarding the headquarters
|
||
function isInParameterString($value, $parString, $delimiter = "|") {
|
||
$retVal = false;
|
||
if ($value != "") :
|
||
if ($delimiter == "|") :
|
||
$delimiter = "-,-";
|
||
$parString = str_replace("|", $delimiter, $parString);
|
||
endif;
|
||
$parArray = spliti($delimiter, $parString);
|
||
$parArrayLen = count($parArray);
|
||
for ($i = 0; $i < $parArrayLen; $i++) :
|
||
if ($value == $parArray[$i]) :
|
||
$retVal = true;
|
||
endif;
|
||
endfor;
|
||
endif;
|
||
return $retVal;
|
||
}
|
||
|
||
// Get the DB fieldname without alias (e.g. "jb.jb_id" => "jb_id")
|
||
function getDBFieldsNameWithoutAlias ($dbFieldName) {
|
||
if (!(strpos($dbFieldName, ".") === FALSE)) :
|
||
$dbFieldName = substr($dbFieldName, strrpos($dbFieldName,".") + 1);
|
||
endif;
|
||
return $dbFieldName;
|
||
}
|
||
|
||
// Get metatype default values for a special object (e.g. customer) as default
|
||
function metatypeSetDefaultValues($mtType, $mtObjType, $mtObjId, $deleteNo = "") {
|
||
$retVal = "ERR";
|
||
if ($mtType != "" && $mtObjType != "" && $mtObjId != "") :
|
||
// Remove existing entries for the specified object ID (e.g. customer)
|
||
if ($deleteNo != "1") :
|
||
deleteStmt("metatype", "mt_type = '" . $mtType . "' AND mt_objtype = '" . $mtObjType . "' AND mt_objid = '" . $mtObjId . "'");
|
||
endif;
|
||
// Take default values of the metatype regarding "mt_type" and inserts all
|
||
$mt = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = '" . $mtType . "' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", "");
|
||
$mtNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = '" . $mtType . "' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", "");
|
||
$mtMappedValues = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = '" . $mtType . "' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", "");
|
||
$mtLen = count($mt);
|
||
for ($i = 0; $i < $mtLen; $i++) :
|
||
insertStmt("metatype", array("mt_type", $mtType, "mt_objtype", $mtObjType, "mt_objid", $mtObjId, "mt_sort", $mt[$i], "mt_value", $mtNames[$i], "mt_mapped_value", $mtMappedValues[$i]));
|
||
endfor;
|
||
$retVal = "";
|
||
endif;
|
||
return $retVal;
|
||
}
|
||
|
||
// Get metatype values (especially "mt_mapped_value") regarding to the type ("mt_type")
|
||
function metatypeGetMappedValues ($mtType, $specialContextVal = "", $mtObjId = "0", $mtObjType = "", $mode = "") {
|
||
$retArray = array();
|
||
if ($mtType != "") :
|
||
// if ($mode == "") : $mode = "0"; endif;
|
||
$valArray = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = '" . $mtType . "' AND mt_objtype = '" . $mtObjType . "' AND mt_objid = '" . $mtObjId . "'", "mt_sort", "mt_sort", "");
|
||
$valArrayLen = count($valArray);
|
||
// Iterate array
|
||
for ($i = 0; $i < $valArrayLen; $i++) :
|
||
if ($mtType == "day_time") :
|
||
if ($mode == "1") :
|
||
$retArray[$i][0] = substr($valArray[$i],0,5) . ":00"; // "08:00 - 12:00" => "08:00"
|
||
$retArray[$i][1] = substr($valArray[$i],8,5) . ":00"; // "08:00 - 12:00" => "12:00"
|
||
elseif ($mode == "") :
|
||
if ($specialContextVal != "" && $specialContextVal != "0") :
|
||
// Converts time range to time units (e.g. 12:00-17:59 => 12_00-17_05) [$hourTimeUnits = $specialContextVal <=> default "6" (0..5) !!!!]
|
||
$retArray[$i][0] = substr($valArray[$i],0,2) . "_" . pad(strval(floor(floatval(substr($valArray[$i],3,2)) / (60 / $specialContextVal))), 2);
|
||
$retArray[$i][1] = substr($valArray[$i],8,2) . "_" . pad(strval(floor(floatval(substr($valArray[$i],11,2)) / (60 / $specialContextVal))), 2);
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endfor;
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
// $in : Array with numeric values (e.g. mt_type = "service" with selection mt_sort <=> (0,1,2,6) <=> (Lieferung, Montage, Aufmaß,Reklamation) <=> Bitstring "1000111")
|
||
function mcConvertSel2Num ($in, $numSystem = "") {
|
||
$retVal = "";
|
||
if ($in != "" && is_array($in)) :
|
||
// Generate "bitstring" from array
|
||
$bitString = "";
|
||
$maxValue = max($in);
|
||
for ($i = 0; $i <= $maxValue; $i++) :
|
||
if (in_array($i, $in)) :
|
||
$bitString = "1" . $bitString;
|
||
else :
|
||
$bitString = "0" . $bitString;
|
||
endif;
|
||
endfor;
|
||
if ($numSystem == "bin") :
|
||
$retVal = $bitString;
|
||
elseif ($numSystem == "dec") :
|
||
$retVal = bindec($bitString);
|
||
elseif ($numSystem == "hex") :
|
||
$retVal = dechex(bindec($bitString));
|
||
else :
|
||
$retVal = bindec($bitString);
|
||
endif;
|
||
endif;
|
||
return $retVal;
|
||
}
|
||
|
||
// Vice versa to function "mcConvertSel2Num"
|
||
function mcConvertNum2Sel ($in, $numSystem = "") {
|
||
$retArray = array();
|
||
if ($in != "" && is_numeric($in)) :
|
||
$bitString = "";
|
||
if ($numSystem == "bin") :
|
||
$bitString = $in;
|
||
elseif ($numSystem == "dec") :
|
||
$bitString = decbin($in);
|
||
elseif ($numSystem == "hex") :
|
||
$bitString = decbin(hexdec($in));
|
||
else :
|
||
$bitString = decbin($in);
|
||
endif;
|
||
$bitStringLen = strlen($bitString) - 1; // Decrement because of "0"
|
||
for ($i = 0; $i <= $bitStringLen; $i++) :
|
||
if (substr($bitString, $i, 1) == "1") :
|
||
$retArray[] = ($bitStringLen - $i);
|
||
endif;
|
||
endfor;
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
// Converts seconds to a human readable format
|
||
function secondsToDate($seconds, $formatString = "") {
|
||
$dtF = new DateTime("@0");
|
||
$dtT = new DateTime("@$seconds");
|
||
if ($formatString == "") : $formatString = "%a " . getLngt("Tage") . ", %h " . getLngt("Std.") . ", %i " . getLngt("Min.") . " %s " . getLngt("Sek."); endif;
|
||
return $dtF->diff($dtT)->format($formatString);
|
||
}
|
||
|
||
// Get vehicle type ID
|
||
function getVhtId ($defaultId, $constName = "") {
|
||
global $hq_id;
|
||
$retId = $defaultId;
|
||
if ($constName != "") :
|
||
$parVehicleTypeMapping = getParameterValue("0", "MASK_VEHICLE_TYPE_MAPPING", $hq_id);
|
||
if ($parVehicleTypeMapping == "") :
|
||
$parVehicleTypeMapping = getParameterValue("0", "MASK_VEHICLE_TYPE_MAPPING", "0");
|
||
endif;
|
||
if ($parVehicleTypeMapping != "") :
|
||
$vhtMappingArray = getKeyValueArrayFromString($parVehicleTypeMapping); // E.g.: 1=2|3=2|4=2 <=> Kombi=PKW|Kastenwagen=PKW
|
||
if ($vhtMappingArray[$constName] != "" && is_numeric($vhtMappingArray[$constName])) :
|
||
// Check exitsence in "metatype"
|
||
$mtIdVht = getFieldValueFromClause("metatype","mt_id","mt_type = 'vehicletype' AND mt_sort = '" . $vhtMappingArray[$constName] . "'");
|
||
if ($mtIdVht != "") :
|
||
$retId = $vhtMappingArray[$constName];
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
return $retId;
|
||
}
|
||
|
||
// Converts matrix (2-dim-array) to vector (1-dim-array) e.g. like "csv-lines"
|
||
function convertMatrixToCsv ($matrix, $headlineStr = "", $delimiter = ";", $hiddenCols = array(), $formatNumCols = array()) {
|
||
$retArray = array();
|
||
if ($headlineStr != "") :
|
||
$retArray[] = $headlineStr;
|
||
endif;
|
||
if (!is_array($hiddenCols) && $hiddenCols != "") :
|
||
$hiddenCols = array($hiddenCols);
|
||
endif;
|
||
if (is_array($matrix)) :
|
||
$matrixLen = count($matrix);
|
||
for ($i = 0; $i < $matrixLen; $i++) :
|
||
$colArray = $matrix[$i];
|
||
$colArrayLen = count($colArray);
|
||
$line = "";
|
||
for ($j = 0; $j < $colArrayLen; $j++) :
|
||
$k = array_search($j, $hiddenCols);
|
||
if ($k === FALSE) :
|
||
$cellContent = $colArray[$j];
|
||
$l = array_search($j, $formatNumCols);
|
||
if (!($l === FALSE)) :
|
||
$cellContent = str_replace (",", ".", $cellContent);
|
||
endif;
|
||
$line .= $cellContent . $delimiter;
|
||
endif;
|
||
endfor;
|
||
$retArray[] = $line;
|
||
endfor;
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
// Converts matrix (2-dim-array) to vector (1-dim-array) e.g. like "csv-lines"
|
||
function convertMatrixToTable ($matrix, $noDisplayTableTag = "", $cssTable = "", $cssTr = "", $cssTd = "") {
|
||
$retValue = "";
|
||
if (is_array($matrix)) :
|
||
if ($noDisplayTableTag != "1") :
|
||
$retValue .= "<table " . $cssTable . ">\n";
|
||
endif;
|
||
$matrixLen = count($matrix);
|
||
for ($i = 0; $i < $matrixLen; $i++) :
|
||
$retValue .= "<tr" . ($cssTr != "" ? " " . $cssTr : "") . ">\n";
|
||
$colArray = $matrix[$i];
|
||
$colArrayLen = count($colArray);
|
||
for ($j = 0; $j < $colArrayLen; $j++) :
|
||
if ($cssTd != "") :
|
||
$cellColor = getListColor($i, $j);
|
||
$retValue .= "<td bgcolor=\"" . $cellColor ."\" " . $cssTd . ">\n";
|
||
$retValue .= $colArray[$j];
|
||
$retValue .= "</td>\n";
|
||
else :
|
||
$retValue .= $colArray[$j]; // Content in $colArray[$j] is like "<td....> .... </td>"
|
||
endif;
|
||
endfor;
|
||
$retValue .= "</tr>\n";
|
||
endfor;
|
||
if ($noDisplayTableTag != "1") :
|
||
$retValue .= "</table>\n";
|
||
endif;
|
||
endif;
|
||
return $retValue;
|
||
}
|
||
|
||
// Gets a single metafield value
|
||
function getMetafieldValue ($mtfcId, $mtfkId, $objId, $hqId = "0") {
|
||
global $db, $PHP_SELF, $hq_id;
|
||
|
||
$retVal = "ERR";
|
||
if ($mtfcId != "" && is_numeric($mtfcId) && $mtfkId != "" && is_numeric($mtfkId) && $objId != "" && is_numeric($objId) && $hqId != "" && is_numeric($hqId)) :
|
||
|
||
$sqlquery = "SELECT mtfv.mtfv_value"
|
||
. " FROM metafieldcategory AS mtfc, metafieldkey AS mtfk, metafieldcategorykey AS mtfck, metafieldvalue AS mtfv"
|
||
. " WHERE mtfk.mtfk_id = '" . $mtfkId . "' AND"
|
||
. " mtfck.mtfc_id = '" . $mtfcId . "' AND"
|
||
. " mtfck.hq_id = '" . $hqId . "' AND"
|
||
. " mtfck.mtfk_id = mtfk.mtfk_id AND"
|
||
. " mtfck.mtfc_id = mtfc.mtfc_id AND"
|
||
. " mtfv.mtfck_id = mtfck.mtfck_id AND"
|
||
. " mtfv.mtfv_id = '" . $objId . "'";
|
||
|
||
$result = $db->dbQ($sqlquery);
|
||
while ($row = $result->fetch_assoc()):
|
||
$retVal = $row["mtfv_value"];
|
||
endwhile;
|
||
$result->free();
|
||
endif;
|
||
return $retVal;
|
||
}
|
||
|
||
// Generate generic parts (field|from|where clause)
|
||
function genericSqlMetafieldJoin ($objectType, $joinNo = "0") {
|
||
global $hq_id;
|
||
$retArray = array("","","","","");
|
||
if ($objectType != "") :
|
||
$parJoinNo = pad($joinNo, "2");
|
||
if ($joinNo == "0" || $joinNo == "1") : $joinNo = ""; endif;
|
||
|
||
$titleExt = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_TITLE_EXT_" . $parJoinNo, $hq_id);
|
||
if ($titleExt == "") : $titleExt = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_TITLE_EXT_" . $parJoinNo, "0"); endif;
|
||
|
||
if ($titleExt != "") :
|
||
$fieldExt = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_FIELD_EXT_" . $parJoinNo, $hq_id);
|
||
if ($fieldExt == "") : $fieldExt = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_FIELD_EXT_" . $parJoinNo, "0"); endif;
|
||
|
||
$fieldClause = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_FIELD_CLAUSE_" . $parJoinNo, $hq_id);
|
||
if ($fieldClause == "") : $fieldClause = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_FIELD_CLAUSE_" . $parJoinNo, "0"); endif;
|
||
if ($fieldClause != "") :
|
||
// $fieldClause = ", mtfv" . $joinNo . ".mtfv_value AS " . $fieldClause;
|
||
$fieldClause = ", mtf.mtfv___value AS " . $fieldClause;
|
||
endif;
|
||
|
||
$fromClause = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_FROM_CLAUSE_" . $parJoinNo, $hq_id);
|
||
if ($fromClause == "") : $fromClause = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_FROM_CLAUSE_" . $parJoinNo, "0"); endif;
|
||
if ($fromClause != "") :
|
||
$tmpArray = getKeyValueArrayFromString($fromClause);
|
||
/*
|
||
$fromClause = " LEFT JOIN metafieldvalue AS mtfv" . $joinNo . " ON mtfv" . $joinNo . ".mtfv_id = " . $tmpArray["OBJ_TYPE"] . "." . $tmpArray["OBJ_ID"]
|
||
. " INNER JOIN metafieldcategorykey AS mtfck" . $joinNo . " ON mtfv" . $joinNo . ".mtfck_id = mtfck" . $joinNo . ".mtfck_id AND mtfck" . $joinNo . ".hq_id = '" . $tmpArray["HQ_ID"] . "' AND mtfck" . $joinNo . ".mtfc_id = '" . $tmpArray["MTFC_ID"] . "'"
|
||
. " INNER JOIN metafieldkey AS mtfk" . $joinNo . " ON mtfck" . $joinNo . ".mtfk_id = mtfk" . $joinNo . ".mtfk_id AND mtfk" . $joinNo . ".mtfk_id = '" . $tmpArray["MTFK_ID"] . "' ";
|
||
*/
|
||
$fromClause = " LEFT JOIN (SELECT mtfv" . $joinNo . ".mtfv_id AS mtfv___id, mtfv" . $joinNo . ".mtfv_value AS mtfv___value"
|
||
. " FROM metafieldvalue AS mtfv" . $joinNo . ", metafieldcategorykey AS mtfck" . $joinNo . ", metafieldkey AS mtfk" . $joinNo
|
||
. " WHERE mtfv" . $joinNo . ".mtfck_id = mtfck" . $joinNo . ".mtfck_id AND mtfck" . $joinNo . ".hq_id = '" . $tmpArray["HQ_ID"] . "' AND mtfck" . $joinNo . ".mtfc_id = '" . $tmpArray["MTFC_ID"] . "' AND"
|
||
. " mtfck" . $joinNo . ".mtfk_id = mtfk" . $joinNo . ".mtfk_id AND mtfk" . $joinNo . ".mtfk_id = '" . $tmpArray["MTFK_ID"] . "' "
|
||
. " ) AS mtf ON mtf.mtfv___id = " . $tmpArray["OBJ_TYPE"] . "." . $tmpArray["OBJ_ID"] . " ";
|
||
endif;
|
||
|
||
$whereClause = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_WHERE_CLAUSE_" . $parJoinNo, $hq_id);
|
||
if ($whereClause == "") : $whereClause = getParameterValue("0", "MTF_SQL_JOIN_" . $objectType . "_WHERE_CLAUSE_" . $parJoinNo, "0"); endif;
|
||
if ($whereClause != "") :
|
||
$whereClause = " AND " . $whereClause;
|
||
endif;
|
||
|
||
$retArray = array($titleExt,$fieldExt,$fieldClause,$fromClause,$whereClause);
|
||
endif;
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
// Get mandatory fields to be checked
|
||
// Data are stored as key-value-pairs (with values "empty = 0 = not mandatory", "1 = mandatory", "2,3,.... = what else...")
|
||
function getMandatoryFields ($dbPar, $delimiter = "|", $delimiter2 = "=") {
|
||
global $hq_id;
|
||
$retArray = array();
|
||
if ($dbPar != "") :
|
||
$parMaskMandatoryFields = getParameterValue("0", $dbPar, $hq_id);
|
||
if ($parMaskMandatoryFields == "") : $parMaskMandatoryFields = getParameterValue("0", $dbPar, "0"); endif;
|
||
if ($parMaskMandatoryFields != "") :
|
||
// E.g.: "br_id=1|tx_id=0|cs_eid=1|....
|
||
$retArray = getKeyValueArrayFromString($parMaskMandatoryFields, $delimiter, $delimiter2);
|
||
endif;
|
||
endif;
|
||
return $retArray;
|
||
}
|
||
|
||
function mcArray2Xml($arr, $tagRoot = "", $lf = "") {
|
||
$retXML = "";
|
||
$applyRootTag = true;
|
||
$arrKeys = array_keys($arr);
|
||
$arrKeysLen = count($arrKeys);
|
||
for ($i = 0; $i < $arrKeysLen; $i++) :
|
||
$key = $arrKeys[$i];
|
||
$val = $arr[$key];
|
||
if (is_array($val)) :
|
||
if (is_numeric($key) && $key == $i) :
|
||
$retXML .= mcArray2Xml($val, $tagRoot, $lf);
|
||
$applyRootTag = false;
|
||
else :
|
||
$retXML .= mcArray2Xml($val, $key, $lf);
|
||
endif;
|
||
elseif (is_bool($val) === true) :
|
||
$retXML .= "<" . $key . ">" . ($val ? "true" : "false") . "</" . $key . ">" . $lf;
|
||
else :
|
||
$retXML .= "<" . $key . ">" . ($val != "" ? "<![CDATA[" . mcEncode($val) . "]]>" : "") . "</" . $key . ">" . $lf;
|
||
endif;
|
||
endfor;
|
||
if ($applyRootTag && $tagRoot != "") :
|
||
$retXML = "<" . $tagRoot . ">" . $lf . $retXML . "</" . $tagRoot . ">" . $lf;
|
||
endif;
|
||
|
||
return $retXML;
|
||
}
|
||
|
||
function isRunning($maxCnt = 1) {
|
||
global $argc, $argv;
|
||
|
||
if ($argc > 0):
|
||
$cnt = 0;
|
||
exec("ps -fA | grep php", $output);
|
||
for ($i = 0; $i < count($output); $i++):
|
||
$pos = strpos ($output[$i], $argv[0]);
|
||
if (!($pos === false))
|
||
$cnt++;
|
||
endfor;
|
||
if ($cnt > $maxCnt):
|
||
$fileHandle = @fopen("../log/global_" . date("Ym") . ".log", 'a');
|
||
@fwrite($fileHandle, "[" . date("Y-m-d H:i:s") . "] " . "$PHP_SELF: [" . $argv[0] . "] is running " . $cnt . " times, maxCnt is " . $maxCnt . " ..." . "\n");
|
||
@fclose($fileHandle);
|
||
return true;
|
||
endif;
|
||
endif;
|
||
return false;
|
||
}
|
||
|
||
function getWebColors ($outputMode = "html") {
|
||
$colPink = array("FFC0CB","FFB6C1","FF69B4","FF1493","DB7093","C71585");
|
||
$colRed = array("FFA07A","FA8072","E9967A","F08080","CD5C5C","DC143C","B22222","8B0000","FF0000");
|
||
$colOrange = array("FF4500","FF6347","FF7F50","FF8C00","FFA500");
|
||
$colYellow = array("FFFF00","FFFFE0","FFFACD","FAFAD2","FFEFD5","FFE4B5","FFDAB9","EEE8AA","F0E68C","BDB76B","FFD700");
|
||
$colBrown = array("FFF8DC","FFEBCD","FFE4C4","FFDEAD","F5DEB3","DEB887","D2B48C","BC8F8F","F4A460","DAA520","B8860B","CD853F","D2691E","8B4513","A0522D","A52A2A","800000");
|
||
$colGreen = array("556B2F","808000","6B8E23","9ACD32","32CD32","00FF00","7CFC00","7FFF00","ADFF2F","00FF7F","00FA9A","90EE90","98FB98","8FBC8F","3CB371","2E8B57","228B22","008000","006400");
|
||
$colCyan = array("66CDAA","00FFFF","00FFFF","E0FFFF","AFEEEE","7FFFD4","48D1CC","00CED1","20B2AA","5F9EA0","008B8B","008080"); // "40E0D0",
|
||
$colBlue = array("B0C4DE","B0E0E6","ADD8E6","87CEEB","87CEFA","00BFFF","6495ED","4682B4","0000FF","0000CD","00008B","000080","191970"); // "1E90FF","4169E1",
|
||
$colViolet = array("E6E6FA","D8BFD8","DDA0DD","EE82EE","DA70D6","FF00FF","FF00FF","BA55D3","9370DB","8A2BE2","9400D3","9932CC","8B008B","800080","4B0082","483D8B","6A5ACD","7B68EE","663399");
|
||
$colWhite = array("FFFAFA","F0FFF0","F5FFFA","F0FFFF","F0F8FF","F8F8FF","F5F5F5","FFF5EE","F5F5DC","FDF5E6","FFFAF0","FFFFF0","FAEBD7","FAF0E6","FFF0F5","FFE4E1");
|
||
$colGray = array("DCDCDC","D3D3D3","C0C0C0","A9A9A9","808080","696969","778899","708090","2F4F4F","000000");
|
||
|
||
$colAll = array("colPink","colRed","colOrange","colYellow","colBrown","colGreen","colCyan","colBlue","colViolet","colGray"); // "colWhite",
|
||
$colAllLen = count($colAll);
|
||
|
||
global $leftColWidth;
|
||
|
||
$output = "";
|
||
if ($outputMode == "html") :
|
||
$output .= htmlDivLineSpacer("10px", "", "left");
|
||
$output = "<div id=\"f_colorpicker\">";
|
||
// No colour
|
||
$output .= "<div>\n";
|
||
$output .= " <div " . setStyleHtmlDiv($leftColWidth,"left") . "> </div>\n";
|
||
$output .= " <div>\n";
|
||
$output .= " <input type=\"button\" style=\"height:20px; width:20px; background-color: #FFFFFF;\" onclick=\"setJobColor('FFFFFF');\"> " . getLngt("[Keine Farbe]") . "\n";
|
||
$output .= " </div>\n";
|
||
$output .= "</div>\n";
|
||
$output .= htmlDivLineSpacer("5px", "", "left");
|
||
// Colour palette
|
||
for ($i = 0; $i < $colAllLen; $i++) :
|
||
$curColArr = ${$colAll[$i]};
|
||
$curColArrLen = count($curColArr);
|
||
// $output .= htmlDivLineSpacer("5px", "", "left");
|
||
$output .= "<div>\n";
|
||
$output .= " <div " . setStyleHtmlDiv($leftColWidth,"left") . "> </div>\n";
|
||
$output .= " <div>\n";
|
||
for ($j = 0; $j < $curColArrLen; $j++) :
|
||
$output .= " <input type=\"button\" style=\"height:15px; width:15px; background-color: #" . $curColArr[$j] . ";\" onclick=\"setJobColor('" . $curColArr[$j] . "');\">\n";
|
||
endfor;
|
||
$output .= " </div>\n";
|
||
$output .= "</div>\n";
|
||
endfor;
|
||
$output .= "</div>\n";
|
||
endif;
|
||
|
||
return $output;
|
||
}
|
||
|
||
// Get country whitelist
|
||
function getNationalityWhitelist () {
|
||
global $globalNationalityWhitelistArr, $globalNationalityWhitelistKeyArr, $globalNationalityDefault;
|
||
if ($globalNationalityDefault == "") :
|
||
$globalNationalityDefault = getParameterValue("0", "GLOBAL_NATIONALITY_DEFAULT", "0");
|
||
if ($globalNationalityDefault == "") :
|
||
$globalNationalityDefault = "DE"; // Init if not set
|
||
endif;
|
||
endif;
|
||
$globalNationalityWhitelist = getParameterValue("0", "GLOBAL_NATIONALITY_WHITELIST", "0");
|
||
$globalNationalityWhitelistArr = getKeyValueArrayFromMultiDelimiterString($globalNationalityWhitelist);
|
||
$globalNationalityWhitelistKeyArr = array_keys($globalNationalityWhitelistArr);
|
||
$globalNationalityWhitelistKeyArrLen = count($globalNationalityWhitelistKeyArr);
|
||
for ($i = 0; $i < $globalNationalityWhitelistKeyArrLen; $i++) :
|
||
$globalNationalityWhitelistArr[$globalNationalityWhitelistKeyArr[$i]] = explode(",", $globalNationalityWhitelistArr[$globalNationalityWhitelistKeyArr[$i]]);
|
||
endfor;
|
||
}
|
||
|
||
// Nationality check for courier regarding job station nationalities
|
||
function checkNationality ($jbId, $objId, $objType = "cr") {
|
||
global $globalNationalityWhitelistArr, $globalNationalityWhitelistKeyArr, $globalNationalityDefault;
|
||
$retBool = true;
|
||
if ($jbId != "" && is_numeric($jbId) && $objId != "" && is_numeric($objId) && $objType != "") :
|
||
if (!isset($globalNationalityWhitelistArr) || !is_array($globalNationalityWhitelistArr)) :
|
||
getNationalityWhitelist(); // Get nationality whitelist for the first time
|
||
endif;
|
||
// Get nationality of the courier
|
||
if ($objType == "cr") :
|
||
$usrId = getFieldValueFromId("courier", "cr_id", $objId, "usr_id");
|
||
elseif ($objType == "cs") :
|
||
$empId = getFieldValueFromId("customer", "cs_id", $objId, "cs_admin");
|
||
$usrId = getFieldValueFromId("employee", "emp_id", $empId, "usr_id");
|
||
elseif ($objType == "usr") :
|
||
$usrId = $objId;
|
||
endif;
|
||
if ($usrId != "" && is_numeric($usrId)) :
|
||
$usrCountry = getFieldValueFromId("user", "usr_id", $usrId, "usr_country");
|
||
if ($usrCountry != "" && $usrCountry != $globalNationalityDefault) :
|
||
// Get all stations of the job and their countries
|
||
$jbTourdata = getFieldValueFromId("job", "jb_id", $jbId, "jb_tourdata");
|
||
$jbTourdataArr = explode("|", $jbTourdata);
|
||
$jbCountries = $jbTourdataArr[2];
|
||
$jbCountryArr = explode(";", $jbCountries);
|
||
$jbCountryArrLen = count($jbCountryArr);
|
||
for ($i = 0; $i < $jbCountryArrLen; $i++) :
|
||
if ($jbCountryArr[$i] != $globalNationalityDefault && $jbCountryArr[$i] != $usrCountry) :
|
||
if (in_array($jbCountryArr[$i], $globalNationalityWhitelistKeyArr)) :
|
||
if (!in_array($usrCountry, $globalNationalityWhitelistArr[$jbCountryArr[$i]])) :
|
||
// NOT found in existing whitelist of the country
|
||
$retBool = false;
|
||
break;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endfor;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
return $retBool;
|
||
}
|
||
|
||
// Quarantine check for association between customer an courier
|
||
function checkNoQuarantine ($jbId, $crId, $hqAll = "") {
|
||
$retBool = true;
|
||
$debug = false;
|
||
if ($debug) : echo "jbId = " . $jbId . "<br>"; endif;
|
||
if ($debug) : echo "crId = " . $crId . "<br>"; endif;
|
||
if ($jbId != "" && is_numeric($jbId) && $crId != "" && is_numeric($crId)) :
|
||
// Get customer ID of the payer of the current job
|
||
$cscIdPayer = getFieldValueFromId("job", "jb_id", $jbId, "csc_id_payer");
|
||
if ($debug) : echo "cscIdPayer = " . $cscIdPayer . "<br>"; endif;
|
||
$csIdPayer = getFieldValueFromId("costcenter", "csc_id", $cscIdPayer, "cs_id");
|
||
if ($debug) : echo "csIdPayer = " . $csIdPayer . "<br>"; endif;
|
||
// Get HQ-ID of the current job
|
||
$whereClauseHQ = "";
|
||
if ($hqAll != "1") :
|
||
$hqId = getFieldValueFromId("job", "jb_id", $jbId, "hq_id");
|
||
$whereClauseHQ = " AND hq_id = '" . $hqId . "'";
|
||
endif;
|
||
if ($debug) : echo "hqId = " . $hqId . "<br>"; endif;
|
||
if ($debug) : echo "whereClauseHQ = [" . $whereClauseHQ . "]<br>"; endif;
|
||
// Get single group ID of the quarantine group of the current headquarters
|
||
// OR get ALL quarantine group IDs of ALL headquarters
|
||
$quarantineGroupIdArray = getColVectorFromDB2ArrayByClause("groups", "grp_id", "grp_name = 'Quarantäne'" . $whereClauseHQ, "", "", "");
|
||
$quarantineGroupIdArrayLen = count($quarantineGroupIdArray);
|
||
$checkCustomerBecauseCourierIsInQuarantine = false;
|
||
for ($i = 0; $i < $quarantineGroupIdArrayLen; $i++) :
|
||
$currGrpId = $quarantineGroupIdArray[$i];
|
||
if ($debug) : echo "currGrpId = " . $currGrpId . "<br><br>"; endif;
|
||
$crGroup = getFieldValueFromId("courier", "cr_id", $crId, "cr_group");
|
||
if (!(strpos($crGroup, "," . $currGrpId . ",") === false)) :
|
||
$checkCustomerBecauseCourierIsInQuarantine = true;
|
||
break 1;
|
||
endif;
|
||
endfor;
|
||
if ($checkCustomerBecauseCourierIsInQuarantine) :
|
||
if ($debug) : echo "Courier is in quarantine! <br>"; endif;
|
||
if ($debug) : echo "Payer (customer) will be checked! <br><br>"; endif;
|
||
// Check for payer of the job being associated to the quarantine group directly
|
||
for ($i = 0; $i < $quarantineGroupIdArrayLen; $i++) :
|
||
$currGrpId = $quarantineGroupIdArray[$i];
|
||
if ($debug) : echo "currGrpId = " . $currGrpId . "<br><br>"; endif;
|
||
$csGroup = getFieldValueFromId("customer", "cs_id", $csIdPayer, "cs_group");
|
||
if (!(strpos($csGroup, "," . $currGrpId . ",") === false)) :
|
||
$retBool = false;
|
||
if ($debug) : echo "Customer is associated directly! <br><br>"; endif;
|
||
break 1;
|
||
endif;
|
||
endfor;
|
||
|
||
// Check for payer of the job having a special branch associated to a quarantine group
|
||
if ($retBool) :
|
||
if ($debug) : echo "Payers branch will be checked! <br><br>"; endif;
|
||
$cmpId = getFieldValueFromId("customer", "cs_id", $csIdPayer, "cmp_id");
|
||
$brId = getFieldValueFromId("company", "cmp_id", $cmpId, "br_id");
|
||
if ($debug) : echo "brId = " . $brId . "<br>"; endif;
|
||
if ($brId != "" && $brId != "0") :
|
||
$brGroup = getFieldValueFromId("branch", "br_id", $brId, "br_group");
|
||
if ($debug) : echo "brGroup = " . $brGroup . "<br>"; endif;
|
||
for ($i = 0; $i < $quarantineGroupIdArrayLen; $i++) :
|
||
$currGrpId = $quarantineGroupIdArray[$i];
|
||
if ($debug) : echo "currGrpId = " . $currGrpId . "<br>"; endif;
|
||
// Check branch groups against quarantine group
|
||
if (!(strpos($brGroup, "," . $currGrpId . ",") === false)) :
|
||
$retBool = false;
|
||
if ($debug) : echo "Payers branch is associated! <br><br>"; endif;
|
||
break 1;
|
||
endif;
|
||
endfor;
|
||
endif;
|
||
endif;
|
||
|
||
// Check for payer of the job being at least in one of the groups because customer is not associated to a quarantine group directly
|
||
// Iterate all groups associated to the quarantine group
|
||
if ($retBool) :
|
||
if ($debug) : echo "Payers groups will be checked! <br><br>"; endif;
|
||
for ($i = 0; $i < $quarantineGroupIdArrayLen; $i++) :
|
||
$currGrpId = $quarantineGroupIdArray[$i];
|
||
if ($debug) : echo "currGrpId = " . $currGrpId . "<br>"; endif;
|
||
// Get all groups associated to quarantine group
|
||
$groupsAssociatedToQuarantineGroupArray = getColVectorFromDB2ArrayByClause("groups", "grp_id", "grp_group LIKE '%," . $currGrpId . ",%'" . $whereClauseHQ, "", "", "");
|
||
$groupsAssociatedToQuarantineGroupArrayLen = count($groupsAssociatedToQuarantineGroupArray);
|
||
for ($j = 0; $j < $groupsAssociatedToQuarantineGroupArrayLen; $j++) :
|
||
if ($debug) : echo "groupsAssociatedToQuarantineGroupArray[j] = " . $groupsAssociatedToQuarantineGroupArray[$j] . "<br><br>"; endif;
|
||
// Get customers of the current group
|
||
$grpCsIdQuarantineArray = getColVectorFromDB2ArrayByClause("customer", "cs_id", "cs_group LIKE '%," . $groupsAssociatedToQuarantineGroupArray[$j] . ",%'" . $whereClauseHQ, "", "", "");
|
||
if ($debug) : echo "grpCsIdQuarantineArray[0] = " . $grpCsIdQuarantineArray[0] . "<br>"; endif;
|
||
if (in_array($csIdPayer, $grpCsIdQuarantineArray)) :
|
||
$retBool = false;
|
||
if ($debug) : echo "One of Payers groups is associated! <br><br>"; endif;
|
||
break 1;
|
||
endif;
|
||
endfor;
|
||
endfor;
|
||
endif;
|
||
|
||
endif;
|
||
endif;
|
||
return $retBool;
|
||
}
|
||
|
||
// Cumulates all courier and couriervehicle checks regarding global jobs
|
||
function checkCr4GlobalJob ($jbId, $hqAll = "0") {
|
||
global $globalNationalityWhitelistArr, $globalNationalityWhitelistKeyArr, $globalNationalityDefault;
|
||
global $debug, $debugArr;
|
||
|
||
$retBool = true;
|
||
$crExcludedArr = array();
|
||
|
||
if ($jbId != "" && is_numeric($jbId)) :
|
||
|
||
// Init
|
||
$gdcContext = "";
|
||
$specialFilter = "EG";
|
||
$specialTotalWeight = "2800";
|
||
|
||
// Get headquarters of the job
|
||
$jbHqId = getFieldValueFromId("job", "jb_id", $jbId, "hq_id");
|
||
$jbHqWhereClause = " cr.hq_id = '" . $jbHqId . "' AND ";
|
||
if ($hqAll == "1") :
|
||
$jbHqWhereClause = "";
|
||
endif;
|
||
|
||
// Get station countries of the job
|
||
$jbTourCountriesAreAllHomeCountry = true; // Init: All stations have "DE"
|
||
$jbTourdata = getFieldValueFromId("job", "jb_id", $jbId, "jb_tourdata");
|
||
$jbTourdataArr = explode("|", $jbTourdata);
|
||
$jbCountries = $jbTourdataArr[2];
|
||
$jbCountryArr = explode(";", $jbCountries);
|
||
$jbCountryArrLen = count($jbCountryArr);
|
||
|
||
|
||
// [I.] Nationality check for courier regarding job station nationalities
|
||
if (!isset($globalNationalityWhitelistArr) || !is_array($globalNationalityWhitelistArr)) :
|
||
getNationalityWhitelist(); // Get nationality whitelist for the first time
|
||
endif;
|
||
// Iterate station countries
|
||
for ($i = 0; $i < $jbCountryArrLen; $i++) :
|
||
if ($jbCountryArr[$i] != $globalNationalityDefault) :
|
||
$jbTourCountriesAreAllHomeCountry = false; // At least one station does not have "DE"
|
||
if (in_array($jbCountryArr[$i], $globalNationalityWhitelistKeyArr)) :
|
||
// Get all couriers to be excluded for the special country
|
||
$tmpCrExcludedArray = getColVectorFromDB2ArrayByClause("courier AS cr, company AS cmp, couriervehicle AS crvh, user AS usr", "cr.cr_id", $jbHqWhereClause . "cr.cr_id = crvh.cr_id AND cr.cmp_id = cmp.cmp_id AND cmp.cmp_authenticated = '1' AND cmp.cmp_visible = '1' AND cmp.cmp_archived = '0' AND cr.usr_id = usr.usr_id AND usr.usr_country NOT IN ('" . implode("','", $globalNationalityWhitelistArr[$jbCountryArr[$i]]) . "')", "", "", "");
|
||
if (count($tmpCrExcludedArray) > 0) :
|
||
$crExcludedArr = array_merge($crExcludedArr, $tmpCrExcludedArray);
|
||
$gdcContext .= "[NATION_CHK:" . $jbCountryArr[$i] . "]";
|
||
endif;
|
||
if ($debug) :
|
||
$debugArr[1] = $tmpCrExcludedArray;
|
||
endif;
|
||
endif;
|
||
endif;
|
||
endfor;
|
||
|
||
// [II.] Quarantine check for association between customer an courier
|
||
if (false) :
|
||
// Get customer ID of the payer of the current job
|
||
$cscIdPayer = getFieldValueFromId("job", "jb_id", $jbId, "csc_id_payer");
|
||
$csIdPayer = getFieldValueFromId("costcenter", "csc_id", $cscIdPayer, "cs_id");
|
||
// Get HQ-ID of the current job
|
||
$whereClauseHQ = "";
|
||
if ($hqAll != "1") :
|
||
$hqId = getFieldValueFromId("job", "jb_id", $jbId, "hq_id");
|
||
$whereClauseHQ = " AND hq_id = '" . $hqId . "'";
|
||
endif;
|
||
// Get single group ID of the quarantine group of the current headquarters
|
||
// OR get ALL quarantine group IDs of ALL headquarters
|
||
$quarantineGroupIdArray = getColVectorFromDB2ArrayByClause("groups", "grp_id", "grp_name = 'Quarantäne'" . $whereClauseHQ, "", "", "");
|
||
$quarantineGroupIdArrayLen = count($quarantineGroupIdArray);
|
||
$checkCustomerBecauseCourierIsInQuarantine = false;
|
||
for ($i = 0; $i < $quarantineGroupIdArrayLen; $i++) :
|
||
$currGrpId = $quarantineGroupIdArray[$i];
|
||
|
||
// Get all couriers to be excluded for quarantine state
|
||
$tmpCrExcludedArray = getColVectorFromDB2ArrayByClause("courier AS cr, company AS cmp", "cr_id", "cr.cmp_id = cmp.cmp_id AND cmp.cmp_authenticated = '1' AND cmp.cmp_visible = '1' AND cmp.cmp_archived = '0' AND cr.cr_group LIKE '%," . $currGrpId . ",%'", "", "", "");
|
||
if (count($tmpCrExcludedArray) > 0) :
|
||
// ....
|
||
|
||
|
||
|
||
$crExcludedArr = array_merge($crExcludedArr, $tmpCrExcludedArray);
|
||
$gdcContext .= "[QUARANTINE_CHK:" . $jbCountryArr[$i] . "]";
|
||
// break 1;
|
||
endif;
|
||
if ($debug) :
|
||
$debugArr[2] = $tmpCrExcludedArray;
|
||
endif;
|
||
endfor;
|
||
endif;
|
||
|
||
// [III.] Third country check
|
||
if (!$jbTourCountriesAreAllHomeCountry) :
|
||
global $db2;
|
||
$eu_countrycodes = getParameterValue("0", "EU_COUNTRYCODES", "0");
|
||
$tmpCrExcludedArray = array();
|
||
$sqlQuery = "SELECT DISTINCT cr.cr_id FROM courier AS cr, couriervehicle AS crvh, company AS cmp"
|
||
. " WHERE " . $jbHqWhereClause . " cr.cmp_id = cmp.cmp_id AND cmp.cmp_authenticated = '1' AND cmp.cmp_visible = '1' AND cmp.cmp_archived = '0' AND crvh.cr_id = cr.cr_id AND crvh.crvh_sid = cr.cr_sid AND"
|
||
. " crvh.crvh_totalweight >= '" . $specialTotalWeight . "' AND crvh.crvh_filter NOT LIKE '%," . $specialFilter . ",%' AND cr.cr_filter NOT LIKE '%," . $specialFilter . ",%'";
|
||
$res = $db2->query($sqlQuery);
|
||
if ($db2->connect_errno) reportDie ("$PHP_SELF: '$sqlQuery'" . $db2->connect_error);
|
||
while ($row = $res->fetch_assoc()):
|
||
$tmpCrExcludedArray[] = $row["cr_id"];
|
||
endwhile;
|
||
$res->free();
|
||
// Check for station countries
|
||
for ($i = 0; $i < $jbCountryArrLen; $i++) :
|
||
if ($jbCountryArr[$i] != $globalNationalityDefault && !strpos($eu_countrycodes, $jbCountryArr[$i]) === false):
|
||
$crExcludedArr = array_merge($crExcludedArr, $tmpCrExcludedArray);
|
||
$gdcContext .= "[3RD_COUNTRY_CHK:" . $jbCountryArr[$i] . "]";
|
||
if ($debug) :
|
||
$debugArr[3] = $tmpCrExcludedArray;
|
||
endif;
|
||
break; // One matched iteration is enough
|
||
endif;
|
||
endfor;
|
||
endif;
|
||
|
||
// Make courier array unique to be stored
|
||
$crExcludedArr = array_unique($crExcludedArr);
|
||
if (count($crExcludedArr) > 0) :
|
||
$gdcContent = implode(",",$crExcludedArr);
|
||
if (existsEntry("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_gen_fieldname", "global_job_excluded_cr_list", "gdc_obj_id", $jbId))) :
|
||
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $gdcContent, "gdc_context", $gdcContext),"gdc_obj_id = '" . $jbId . "' AND gdc_gen_fieldname = 'global_job_excluded_cr_list'");
|
||
else :
|
||
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbId, "gdc_gen_fieldname", "global_job_excluded_cr_list", "gdc_content", $gdcContent, "gdc_context", $gdcContext));
|
||
endif;
|
||
$retBool = false;
|
||
endif;
|
||
endif;
|
||
return $retBool;
|
||
}
|
||
|
||
// Gets the required number of photos of the last station of a job to be stored into the GDC
|
||
function photosToBeMadeForLastStation ($jbId) {
|
||
global $db, $PHP_SELF;
|
||
$err = 0;
|
||
$trIdLast = "";
|
||
if ($jbId != "" && is_numeric($jbId) && $jbId > 0) :
|
||
if (!($trIdLast != "" && is_numeric($trIdLast) && $trIdLast > 0)) :
|
||
|
||
// Get tr_id of the last station of the job
|
||
$trSort = getMaxOfField("tour", "tr_sort", "jb_id = '" . $jbId . "'");
|
||
if ($trSort != "" && is_numeric($trSort) && $trSort > 0) :
|
||
|
||
// Get station ID of the last station
|
||
$trIdLast = getFieldValueFromClause("tour", "tr_id", "jb_id = '" . $jbId . "' AND tr_sort = '" . $trSort . "'");
|
||
if ($trIdLast != "" && is_numeric($trIdLast) && $trIdLast > 0) :
|
||
|
||
// Get number of photos of the last station
|
||
$numOfPhotos = 0;
|
||
$trPhotosLastStation = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'tr' AND gdc_obj_id = '" . $trIdLast . "' AND gdc_gen_fieldname = 'tr_photo'");
|
||
if ($trPhotosLastStation != "") :
|
||
$tmpArr = explode("|", $trPhotosLastStation);
|
||
$numOfPhotos = $tmpArr[0];
|
||
if (!($numOfPhotos != "" && is_numeric($numOfPhotos) && $numOfPhotos >= 0)) :
|
||
$numOfPhotos = 0;
|
||
endif;
|
||
endif;
|
||
|
||
// Generate or update GDC emtry for the last station
|
||
if (existsEntry("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_gen_fieldname", "photos_last_station", "gdc_obj_id", $jbId))) :
|
||
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $numOfPhotos, "gdc_context", $trIdLast),"gdc_obj_id = '" . $jbId . "' AND gdc_gen_fieldname = 'photos_last_station'");
|
||
else :
|
||
if ($numOfPhotos > 0) :
|
||
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbId, "gdc_gen_fieldname", "photos_last_station", "gdc_content", $numOfPhotos, "gdc_context", $trIdLast));
|
||
endif;
|
||
endif;
|
||
else :
|
||
$err = 103; // Station ID
|
||
endif;
|
||
else :
|
||
$err = 102; // Station counter [tr_sort]
|
||
endif;
|
||
endif;
|
||
else :
|
||
$err = 101; // Job ID
|
||
endif;
|
||
return $err;
|
||
}
|
||
|
||
// Initial inserts of all job semaphors
|
||
function initJobSemaphors ($jbId) {
|
||
global $db, $PHP_SELF;
|
||
$err = 0;
|
||
if ($jbId != "" && is_numeric($jbId) && $jbId > 0) :
|
||
$semaphorKeyArr = array("automailer", "automailer2", "automailer3", "automailer5", "automailer6", "automailer7", "jb_job_jam");
|
||
$semaphorKeyArrLen = count($semaphorKeyArr);
|
||
$currentTime = getDateTime("0");
|
||
for ($i = 0; $i < $semaphorKeyArrLen; $i++) :
|
||
$semaphorKey = $semaphorKeyArr[$i];
|
||
if (!existsEntry("phoenix_log.semaphor",array("sp_obj_type", "jb", "sp_obj_id", $jbId, "sp_fieldname", $semaphorKey))) :
|
||
$res = insertStmt("phoenix_log.semaphor", array("sp_obj_type", "jb", "sp_obj_id", $jbId, "sp_fieldname", $semaphorKey, "sp_content", "", "sp_context", "INIT", "sp_createtime", $currentTime));
|
||
endif;
|
||
endfor;
|
||
else :
|
||
$err = 101; // Job ID
|
||
endif;
|
||
return $err;
|
||
}
|
||
|
||
// Insert special current vehicle field value into jobprice
|
||
function insertJobpriceByVehicleFieldvalue ($jbId, $crvhFieldName, $mtSort) {
|
||
global $db, $PHP_SELF;
|
||
$err = 0;
|
||
if ($jbId != "" && is_numeric($jbId) && $jbId > 0 && $crvhFieldName != "" && $mtSort != "" && is_numeric($mtSort)) :
|
||
|
||
$jbFinishtime = getFieldValueFromId("job", "jb_id", $jbId, "jb_finishtime");
|
||
$crId = getFieldValueFromId("job", "jb_id", $jbId, "cr_id");
|
||
$crSid = getFieldValueFromId("job", "jb_id", $jbId, "cr_sid");
|
||
|
||
$crvhFieldValue = "0";
|
||
if ($crId != "" && is_numeric($crId) && $crId > 0 && $crSid != "") :
|
||
$crvhId = getFieldValueFromClause("couriervehicle", "crvh_id", "cr_id = '" . $crId . "' AND crvh_sid = '" . $crSid . "'");
|
||
if ($crvhId && $jbFinishtime != "" && $jbFinishtime != "0000-00-00 00:00:00") :
|
||
$crvhFieldValue = getServicePriceHistoryValues("crvh", $crvhId, $crvhFieldName, $jbFinishtime);
|
||
endif;
|
||
|
||
// Fallback
|
||
if ($crvhFieldValue == "0") :
|
||
// $crvhFieldValue = getFieldValueFromClause("couriervehicle", $crvhFieldName, "cr_id = '" . $crId . "' AND crvh_sid = '" . $crSid . "'");
|
||
endif;
|
||
endif;
|
||
|
||
// Insert requested vehicle field value in "jobprice"
|
||
if (existsEntry("jobprice", array("jb_id", $jbId, "mt_sort", $mtSort))) :
|
||
updateStmt("jobprice","jb_id",$jbId,array("jbprc_price", $crvhFieldValue, "jbprc_remark", $crvhFieldName),"mt_sort = '" . $mtSort . "'");
|
||
else :
|
||
insertStmt("jobprice", array("jb_id", $jbId, "mt_sort", $mtSort, "jbprc_price", $crvhFieldValue, "jbprc_remark ", $crvhFieldName));
|
||
endif;
|
||
else :
|
||
$err = 101; // Job ID
|
||
endif;
|
||
return $err;
|
||
}
|
||
|
||
// Insert special current vehicle field value into jobprice
|
||
// $retVal : 0 = Update ok; 1 = User empty or not found, no update; 2 = User found, but no update (2FA not avtivated?!)
|
||
function user2FARemove ($objId, $objType) {
|
||
global $db, $PHP_SELF, $hq_id, $usr_id;
|
||
$opState = 1;
|
||
$statusMessage = getLngt("Der Benutzer wurde nicht gefunden!");
|
||
if ($objId != "" && is_numeric($objId) && $objId > 0 && ($objType == "emp" || $objType == "cr" || $objType == "cs")) :
|
||
$opState = 2;
|
||
$statusMessage = getLngt("Es erfolgte keine Deaktivierung! Vermutlich war die 2-FA nicht aktiv!");
|
||
$crId = 0; $csId = 0; $empId = 0; $usrId = 0;
|
||
if ($objType == "cr") :
|
||
$crId = $objId;
|
||
$usrId = getFieldValueFromId("courier", "cr_id", $objId, "usr_id");
|
||
elseif ($objType == "cs") :
|
||
$csId = $objId;
|
||
$empId = getFieldValueFromId("customer", "cs_id", $objId, "cs_admin");
|
||
$usrId = getFieldValueFromId("employee", "emp_id", $empId, "usr_id");
|
||
elseif ($objType == "emp") :
|
||
$usrId = getFieldValueFromId("employee", "emp_id", $objId, "usr_id");
|
||
endif;
|
||
if ($usrId != "" && is_numeric($usrId) && $usrId > 0) :
|
||
$res = updateStmt("user", "usr_id", $usrId, array("usr_totp_secret", "", "usr_totp_activated", "0", "usr_totp_sessionkey", ""), "usr_totp_secret != '' AND usr_totp_activated = '1'");
|
||
if ($db->affected_rows > 0) :
|
||
$opState = 0;
|
||
$statusMessage = getLngt("Die Deaktivierung erfolgte!");
|
||
endif;
|
||
endif;
|
||
endif;
|
||
// Write logdata into log database
|
||
writeToLogDB("184",$hq_id,"",$usr_id,$crId,"",$csId,"STATE=" . $opState . "|USR_ID=" . $usrId);
|
||
return array($opState, $statusMessage);
|
||
}
|
||
|
||
function get_api_key() {
|
||
static $api_keys = NULL;
|
||
|
||
if (is_null($api_keys)) {
|
||
global $dblogin, $dbpassword;
|
||
$db_geo = getDbConnectionSpecial("172.16.0.111:3711", "phoenix", $dblogin, $dbpassword);
|
||
$res = $db_geo->query('SET NAMES latin1');
|
||
if (DB::isError($res)) reportDie ("$PHP_SELF: 'SET NAMES latin1' : " . $res->getMessage());
|
||
$api_keys = explode(",", $db_geo->getOne("SELECT par_value FROM parameter WHERE par_key = 'GOOGLE_MAPS_API_KEY'"));
|
||
}
|
||
return trim($api_keys[rand(0, 1)]);
|
||
}
|
||
|
||
// Insert value into a special field (e.g. user) and set the export flag
|
||
function userSetFieldAndExportFlag ($objId, $objType, $dbFieldName, $dbFieldvalue) {
|
||
global $db, $PHP_SELF, $hq_id, $usr_id;
|
||
$opState = 1;
|
||
$statusMessage = getLngt("Der Daten wurden nicht korrekt übergeben!");
|
||
$logoId = "197"; // Init for "cs"
|
||
$dbFieldName = trim($dbFieldName);
|
||
$dbFieldvalue = trim($dbFieldvalue);
|
||
if ($dbFieldName != "" && $dbFieldvalue != "") :
|
||
$opState = 2;
|
||
$statusMessage = getLngt("Der Benutzer oder der Kunde/Transporteur wurde nicht korrekt übergeben!");
|
||
if ($objId != "" && is_numeric($objId) && $objId > 0 && ($objType == "cmp" || $objType == "cs" || $objType == "cr" || $objType == "usr")) :
|
||
$cmpId = 0; $crId = 0; $csId = 0; $empId = 0; $usrId = 0;
|
||
if ($objType == "cr") :
|
||
$crId = $objId;
|
||
$usrId = getFieldValueFromId("courier", "cr_id", $objId, "usr_id");
|
||
$cmpId = getFieldValueFromId("courier", "cr_id", $objId, "cmp_id");
|
||
$logoId = "198";
|
||
elseif ($objType == "cs") :
|
||
$csId = $objId;
|
||
$cmpId = getFieldValueFromId("customer", "cs_id", $csId, "cmp_id");
|
||
$empId = getFieldValueFromId("customer", "cs_id", $objId, "cs_admin");
|
||
$usrId = getFieldValueFromId("employee", "emp_id", $empId, "usr_id");
|
||
elseif ($objType == "usr") :
|
||
$usrId = $objId;
|
||
$usrType = getFieldValueFromId("user", "usr_id", $usrId, "usr_type");
|
||
if ($usrType == "2") : // Customer
|
||
$empId = getFieldValueFromId("employee", "usr_id", $usrId, "emp_id");
|
||
$csId = getFieldValueFromId("customer", "cs_admin", $empId, "cs_id");
|
||
$cmpId = getFieldValueFromId("customer", "cs_id", $csId, "cmp_id");
|
||
elseif ($usrType == "3") : // Courier
|
||
$crId = getFieldValueFromId("courier", "usr_id", $usrId, "cr_id");
|
||
$cmpId = getFieldValueFromId("courier", "cr_id", $crId, "cmp_id");
|
||
$logoId = "198";
|
||
endif;
|
||
endif;
|
||
$updatedUsr = false; $updatedCmp = false;
|
||
if ($usrId != "" && is_numeric($usrId) && $usrId > 0) :
|
||
$res = updateStmt("user", "usr_id", $usrId, array($dbFieldName, $dbFieldvalue));
|
||
if ($db->affected_rows > 0) :
|
||
$updatedUsr = true;
|
||
endif;
|
||
endif;
|
||
if ($cmpId != "" && is_numeric($cmpId) && $cmpId > 0) :
|
||
$res = updateStmt("company", "cmp_id", $cmpId, array("cmp_modify_status", "2"), "cmp_modify_status = '0'");
|
||
if ($db->affected_rows > 0) :
|
||
// ....
|
||
endif;
|
||
$updatedCmp = true; // True if "cmpId" does exist!
|
||
endif;
|
||
if ($updatedUsr && $updatedCmp) :
|
||
$opState = 0;
|
||
$statusMessage = getLngt("OK!");
|
||
else :
|
||
$opState = 3;
|
||
$statusMessage = getLngt("Das Update war nicht erfolgreich!");
|
||
endif;
|
||
endif;
|
||
endif;
|
||
// Write logdata into log database
|
||
writeToLogDB($logoId,$hq_id,"",$usr_id,$crId,"",$csId,"STATE=" . $opState . "|USR_ID=" . $usrId);
|
||
return array($opState, $statusMessage);
|
||
}
|
||
|
||
function mcCheckCondition (mixed $value, string $operator, mixed $compareValue): bool {
|
||
// "match" directly delivers true or false
|
||
return match ($operator) {
|
||
'==' => $value == $compareValue,
|
||
'!=' => $value != $compareValue,
|
||
'<' => $value < $compareValue,
|
||
'>' => $value > $compareValue,
|
||
'<=' => $value <= $compareValue,
|
||
'>=' => $value >= $compareValue,
|
||
default => false,
|
||
};
|
||
}
|
||
|
||
$srv_names_PZM = array(
|
||
1 => array(
|
||
"zone_1_km" => "KM-Preis Bremen",
|
||
"zone_1_fix" => "Aufschlag Bremen",
|
||
"zone_1_eap" => "KM-Preis An-/Abfahrt Bremen",
|
||
"zone_1_min" => "Mindestpreis Bremen",
|
||
"zone_2_km" => "KM-Preis Bremen-Nord",
|
||
"zone_2_fix" => "Aufschlag Bremen-Nord",
|
||
"zone_2_eap" => "KM-Preis An-/Abfahrt Bremen-Nord",
|
||
"zone_2_min" => "Mindestpreis Bremen-Nord",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"ausserhalb_min" => "Mindestpreis Ausserhalb",
|
||
"zone_faehre_lemwerder-vegesack_km" => "KM-Preis Fähre Vegesack",
|
||
"zone_faehre_lemwerder-vegesack_fix" => "Aufschlag Fähre Vegesack",
|
||
"zone_faehre_lemwerder-vegesack_eap" => "KM-Preis An-/Abfahrt Fähre Vegesack",
|
||
"zone_faehre_motzen-blumenthal_km" => "KM-Preis Fähre Blumenthal",
|
||
"zone_faehre_motzen-blumenthal_fix" => "Aufschlag Fähre Blumenthal",
|
||
"zone_faehre_motzen-blumenthal_eap" => "KM-Preis An-/Abfahrt Fähre Blumenthal",
|
||
"zone_faehre_berne-farge_km" => "KM-Preis Fähre Farge",
|
||
"zone_faehre_berne-farge_fix" => "Aufschlag Fähre Farge",
|
||
"zone_faehre_berne-farge_eap" => "KM-Preis An-/Abfahrt Fähre Farge",
|
||
"zone_faehre_brhv-blexen_km" => "KM-Preis Fähre BRHV-Blexen",
|
||
"zone_faehre_brhv-blexen_fix" => "Aufschlag Fähre BRHV-Blexen",
|
||
"zone_faehre_brhv-blexen_eap" => "KM-Preis An-/Abfahrt Fähre BRHV-Blexen",
|
||
"zone_faehre_brake-sandstedt_km" => "KM-Preis Fähre Brake-Sandstedt",
|
||
"zone_faehre_brake-sandstedt_fix" => "Aufschlag Fähre Brake-Sandstedt",
|
||
"zone_faehre_brake-sandstedt_eap" => "KM-Preis An-/Abfahrt Fähre Brake-Sandstedt",
|
||
"runden" => true
|
||
),
|
||
2 => array(
|
||
"zone_downtown_1_km" => "KM-Preis Innenstadt",
|
||
"zone_downtown_1_fix" => "Aufschlag Innenstadt",
|
||
"zone_downtown_1_eap" => "KM-Preis An-/Abfahrt Innenstadt",
|
||
"zone_downtown_1_min" => "Mindestpreis Innenstadt",
|
||
// "zone_downtown_2_km" => "KM-Preis Innenstadt",
|
||
// "zone_downtown_2_fix" => "Aufschlag Innenstadt",
|
||
// "zone_downtown_2_eap" => "KM-Preis An-/Abfahrt Innenstadt",
|
||
// "zone_downtown_2_min" => "Mindestpreis Innenstadt",
|
||
"zone_stadtgebiet_km" => "KM-Preis Stadtgebiet",
|
||
"zone_stadtgebiet_fix" => "Aufschlag Stadtgebiet",
|
||
"zone_stadtgebiet_eap" => "KM-Preis An-/Abfahrt Stadtgebiet",
|
||
"zone_stadtgebiet_min" => "Mindestpreis Stadtgebiet",
|
||
"zone_elbtunnel_km" => "KM-Preis Elbtunnel",
|
||
"zone_elbtunnel_fix" => "Aufschlag Elbtunnel",
|
||
"zone_elbtunnel_eap" => "KM-Preis An-/Abfahrt Elbtunnel",
|
||
"zone_elbtunnel_min" => "Mindestpreis Elbtunnel",
|
||
"zone_airport_zone_km" => "KM-Preis Flughafen",
|
||
"zone_airport_zone_fix" => "Aufschlag Flughafen",
|
||
"zone_airport_zone_eap" => "KM-Preis An-/Abfahrt Flughafen",
|
||
"zone_airport_zone_min" => "Mindestpreis Flughafen",
|
||
// "zone_terminal_delivery_zone_km" => "KM-Preis Flughafen",
|
||
// "zone_terminal_delivery_zone_fix" => "Aufschlag Flughafen",
|
||
// "zone_terminal_delivery_zone_eap" => "KM-Preis An-/Abfahrt Flughafen",
|
||
// "zone_terminal_delivery_zone_min" => "Mindestpreis Flughafen",
|
||
// "zone_cargo_main_entry_zone_km" => "KM-Preis Flughafen",
|
||
// "zone_cargo_main_entry_zone_fix" => "Aufschlag Flughafen",
|
||
// "zone_cargo_main_entry_zone_eap" => "KM-Preis An-/Abfahrt Flughafen",
|
||
// "zone_cargo_main_entry_zone_min" => "Mindestpreis Flughafen",
|
||
// "zone_cargo_secondary_entry_zone_km" => "KM-Preis Flughafen",
|
||
// "zone_cargo_secondary_entry_zone_fix" => "Aufschlag Flughafen",
|
||
// "zone_cargo_secondary_entry_zone_eap" => "KM-Preis An-/Abfahrt Flughafen",
|
||
// "zone_cargo_secondary_entry_zone_min" => "Mindestpreis Flughafen",
|
||
"zone_uke_km" => "KM-Preis UKE",
|
||
"zone_uke_fix" => "Aufschlag UKE",
|
||
"zone_uke_eap" => "KM-Preis An-/Abfahrt UKE",
|
||
"zone_uke_min" => "Mindestpreis UKE",
|
||
"zone_umland_km" => "KM-Preis Umland",
|
||
"zone_umland_fix" => "Aufschlag Umland",
|
||
"zone_umland_eap" => "KM-Preis An-/Abfahrt Umland",
|
||
"zone_umland_min" => "Mindestpreis Umland",
|
||
"zone_sylt_hindenburgdamm_km" => "KM-Preis Hindenburgdamm",
|
||
"zone_sylt_hindenburgdamm_fix" => "Aufschlag Hindenburgdamm",
|
||
"zone_sylt_hindenburgdamm_eap" => "KM-Preis An-/Abfahrt Hindenburgdamm",
|
||
"zone_sylt_hindenburgdamm_min" => "Mindestpreis Hindenburgdamm",
|
||
"zone_glückstadt_fähre_km" => "KM-Preis Fähre Glückstadt",
|
||
"zone_glückstadt_fähre_fix" => "Aufschlag Fähre Glückstadt",
|
||
"zone_glückstadt_fähre_eap" => "KM-Preis An-/Abfahrt Fähre Glückstadt",
|
||
"zone_glückstadt_fähre_min" => "Mindestpreis Fähre Glückstadt",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"ausserhalb_min" => "Mindestpreis Ausserhalb",
|
||
"runden" => false
|
||
),
|
||
3 => array(
|
||
"zone_1_km" => "KM-Preis Zone 1",
|
||
"zone_1_fix" => "Aufschlag Zone 1",
|
||
"zone_1_eap" => "KM-Preis An-/Abfahrt Zone 1",
|
||
"zone_1_min" => "Mindestpreis Zone 1",
|
||
"zone_2_km" => "KM-Preis Zone 2",
|
||
"zone_2_fix" => "Aufschlag Zone 2",
|
||
"zone_2_eap" => "KM-Preis An-/Abfahrt Zone 2",
|
||
"zone_2_min" => "Mindestpreis Zone 2",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"ausserhalb_min" => "Mindestpreis Ausserhalb",
|
||
"runden" => false
|
||
),
|
||
4 => array(
|
||
// "zone_1_km" => "KM-Preis Innenstadt",
|
||
// "zone_1_fix" => "Aufschlag Innenstadt",
|
||
// "zone_1_eap" => "KM-Preis An-/Abfahrt Innenstadt",
|
||
// "zone_1_min" => "Mindestpreis Innenstadt",
|
||
"zone_1_km" => "KM-Preis Zone 1",
|
||
"zone_1_fix" => "Aufschlag Zone 1",
|
||
"zone_1_eap" => "KM-Preis An-/Abfahrt Zone 1",
|
||
"zone_1_min" => "Mindestpreis Zone 1",
|
||
"zone_2_km" => "KM-Preis Zone 2",
|
||
"zone_2_fix" => "Aufschlag Zone 2",
|
||
"zone_2_eap" => "KM-Preis An-/Abfahrt Zone 2",
|
||
"zone_2_min" => "Mindestpreis Zone 2",
|
||
"zone_mhh_km" => "KM-Preis MHH",
|
||
"zone_mhh_fix" => "Aufschlag MHH",
|
||
"zone_mhh_eap" => "KM-Preis An-/Abfahrt MHH",
|
||
"zone_mhh_min" => "Mindestpreis MHH",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"ausserhalb_min" => "Mindestpreis Ausserhalb",
|
||
"runden" => true
|
||
),
|
||
5 => array(
|
||
"zone_1_km" => "KM-Preis Zone 1",
|
||
"zone_1_fix" => "Aufschlag Zone 1",
|
||
"zone_1_eap" => "KM-Preis An-/Abfahrt Zone 1",
|
||
"zone_1_min" => "Mindestpreis Zone 1",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"ausserhalb_min" => "Mindestpreis Ausserhalb",
|
||
"runden" => false
|
||
),
|
||
6 => array(
|
||
"zone_1_km" => "KM-Preis Zone 1",
|
||
"zone_1_fix" => "Aufschlag Zone 1",
|
||
"zone_1_eap" => "KM-Preis An-/Abfahrt Zone 1",
|
||
"zone_2_km" => "KM-Preis Zone 2",
|
||
"zone_2_fix" => "Aufschlag Zone 2",
|
||
"zone_2_eap" => "KM-Preis An-/Abfahrt Zone 2",
|
||
// "zone_3_km" => "KM-Preis Zone 3",
|
||
// "zone_3_fix" => "Aufschlag Zone 3",
|
||
// "zone_3_eap" => "KM-Preis An-/Abfahrt Zone 3",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"runden" => false
|
||
),
|
||
7 => array(
|
||
"zone_1_km" => "KM-Preis Zone 1",
|
||
"zone_1_fix" => "Aufschlag Zone 1",
|
||
"zone_1_eap" => "KM-Preis An-/Abfahrt Zone 1",
|
||
"zone_1_min" => "Mindestpreis Zone 1",
|
||
// "zone_2_km" => "KM-Preis Zone 2",
|
||
// "zone_2_fix" => "Aufschlag Zone 2",
|
||
// "zone_2_eap" => "KM-Preis An-/Abfahrt Zone 2",
|
||
// "zone_2_min" => "Mindestpreis Zone 2",
|
||
// "zone_3_km" => "KM-Preis Zone 3",
|
||
// "zone_3_fix" => "Aufschlag Zone 3",
|
||
// "zone_3_eap" => "KM-Preis An-/Abfahrt Zone 3",
|
||
// "zone_3_min" => "Mindestpreis Zone 3",
|
||
// "zone_4_km" => "KM-Preis Zone 4",
|
||
// "zone_4_fix" => "Aufschlag Zone 4",
|
||
// "zone_4_eap" => "KM-Preis An-/Abfahrt Zone 4",
|
||
// "zone_4_min" => "Mindestpreis Zone 3",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"ausserhalb_min" => "Mindestpreis Ausserhalb",
|
||
"runden" => false
|
||
),
|
||
8 => array(
|
||
// "zone_1_km" => "KM-Preis City",
|
||
// "zone_1_fix" => "Aufschlag City",
|
||
// "zone_1_eap" => "KM-Preis An-/Abfahrt City",
|
||
// "zone_1_min" => "Mindestpreis City",
|
||
"zone_1_km" => "KM-Preis Kern Leipzig",
|
||
"zone_1_fix" => "Aufschlag Kern Leipzig",
|
||
"zone_1_eap" => "KM-Preis An-/Abfahrt Kern Leipzig",
|
||
"zone_1_min" => "Mindestpreis Kern Leipzig",
|
||
// "zone_2_km" => "KM-Preis Kern Leipzig",
|
||
// "zone_2_fix" => "Aufschlag Kern Leipzig",
|
||
// "zone_2_eap" => "KM-Preis An-/Abfahrt Kern Leipzig",
|
||
// "zone_2_min" => "Mindestpreis Kern Leipzig",
|
||
"ausserhalb_km" => "KM-Preis Ausserhalb",
|
||
"ausserhalb_fix" => "Aufschlag Ausserhalb",
|
||
"ausserhalb_eap" => "KM-Preis An-/Abfahrt Ausserhalb",
|
||
"ausserhalb_min" => "Mindestpreis Ausserhalb",
|
||
"runden" => false
|
||
)
|
||
);
|
||
?>
|