\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 . " "; endif;
if ($debug) : echo "crId = " . $crId . " "; 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 . " "; endif;
$csIdPayer = getFieldValueFromId("costcenter", "csc_id", $cscIdPayer, "cs_id");
if ($debug) : echo "csIdPayer = " . $csIdPayer . " "; 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 . " "; endif;
if ($debug) : echo "whereClauseHQ = [" . $whereClauseHQ . "] "; 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 . "
"; 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! "; endif;
if ($debug) : echo "Payer (customer) will be checked!
"; 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 . "
"; endif;
$csGroup = getFieldValueFromId("customer", "cs_id", $csIdPayer, "cs_group");
if (!(strpos($csGroup, "," . $currGrpId . ",") === false)) :
$retBool = false;
if ($debug) : echo "Customer is associated directly!
"; 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!
"; endif;
$cmpId = getFieldValueFromId("customer", "cs_id", $csIdPayer, "cmp_id");
$brId = getFieldValueFromId("company", "cmp_id", $cmpId, "br_id");
if ($debug) : echo "brId = " . $brId . " "; endif;
if ($brId != "" && $brId != "0") :
$brGroup = getFieldValueFromId("branch", "br_id", $brId, "br_group");
if ($debug) : echo "brGroup = " . $brGroup . " "; endif;
for ($i = 0; $i < $quarantineGroupIdArrayLen; $i++) :
$currGrpId = $quarantineGroupIdArray[$i];
if ($debug) : echo "currGrpId = " . $currGrpId . " "; endif;
// Check branch groups against quarantine group
if (!(strpos($brGroup, "," . $currGrpId . ",") === false)) :
$retBool = false;
if ($debug) : echo "Payers branch is associated!
"; 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!
"; endif;
for ($i = 0; $i < $quarantineGroupIdArrayLen; $i++) :
$currGrpId = $quarantineGroupIdArray[$i];
if ($debug) : echo "currGrpId = " . $currGrpId . " "; 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] . "
"; 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] . " "; endif;
if (in_array($csIdPayer, $grpCsIdQuarantineArray)) :
$retBool = false;
if ($debug) : echo "One of Payers groups is associated!
"; 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
)
);
?>