0) :
for ($i = 0; $i < $cscVectorOfTheCustomerArrayLen; $i++) :
if (existsEntry("job",array("csc_id_payer",$cscVectorOfTheCustomerArray[$i])) || existsEntry("job",array("csc_id_payer_cash",$cscVectorOfTheCustomerArray[$i]))) :
if ($f_cmp_type != "0") :
updateStmt("company","cmp_id",$companyId,array("cmp_type","0"));
$f_cmp_type = "0";
$f_cmp_current_type = "0";
endif;
$showCmpTypeSelection = false;
break;
endif;
endfor;
endif;
endif;
// Get title
$typeTextArray = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'customer_type'", "", "mt_sort", "");
$pageTitel = getLngt("KUNDE");
if ($f_cmp_type == "1") :
$pageTitel = getLngt("INTERESSENT");
elseif ($f_cmp_type == "2") :
$pageTitel = getLngt("POTENTIALKUNDE");
elseif ($f_cmp_type == "3") :
$pageTitel = getLngt("WUNSCHKUNDE");
endif;
if ($f_cmp_type != "" && $typeTextArray[$f_cmp_type] != "") :
$pageTitel = strtoupper($typeTextArray[$f_cmp_type]);
endif;
$deactivateMenuStatic = "1";
if ($generatePDF != "1") :
include_once ("../geo/geocode.inc.php");
endif;
include_once ("../admin/menu.php");
include_once ("../include/html.inc.php");
include_once ("../groupware/calendar.php");
$debug = false;
include_once ("../include/inc_customer.inc.php");
getCurrentScript(__FILE__);
// No operation if print version requested
if ($printVersion == "1") : $f_act = ""; endif;
$addressValidationErr = "";
$dbOperationCompleted = "0";
// Check for validation of the address assigned to the customer
$noValidationOfAddress = FALSE;
if ($f_noaddressvalidation != "") :
if ($f_noaddressvalidation[0] == '1') : $noValidationOfAddress = TRUE; endif;
endif;
// Init parameters:
// Tracking
if (mcChkValOrArrCountIsEmpty($f_cs_tracking)) :
$f_cs_tracking = "0";
else :
if (is_array($f_cs_tracking)) :
mcArrIsSet($f_cs_tracking, 0, 0);
mcArrIsSet($f_cs_tracking, 1, 0);
$f_cs_tracking = $f_cs_tracking[0] + $f_cs_tracking[1];
else :
$f_cs_tracking = "0";
endif;
endif;
// Average charging time
if ($f_cs_charging_time == "") :
$f_cs_charging_time = "0";
endif;
// Average charging time
if ($f_cs_blur_markup_time == "") :
$f_cs_blur_markup_time = "0";
endif;
// Invoice mode
if ($f_cmp_inv2hq == "" || count($f_cmp_inv2hq) == 0) :
$f_cmp_inv2hq = "0";
else :
mcArrIsSet($f_cmp_inv2hq, 0, 0);
mcArrIsSet($f_cmp_inv2hq, 1, 0);
$f_cmp_inv2hq = $f_cmp_inv2hq[0] + $f_cmp_inv2hq[1];
endif;
// Only favoured couriers
if ($f_cs_cr_fav_only == "" || count($f_cs_cr_fav_only) == 0) :
$f_cs_cr_fav_only = "0";
else:
$f_cs_cr_fav_only = "1";
endif;
// Flag for "list customer" (jobbatch)
if ($f_cs_jobbatch == "" || count($f_cs_jobbatch) == 0) :
$f_cs_jobbatch = "0";
else:
$f_cs_jobbatch = "1";
endif;
// Flag for fixprice discount
if ($f_cs_fixprice_discount == "" || count($f_cs_fixprice_discount) == 0) :
$f_cs_fixprice_discount = "0";
else:
$f_cs_fixprice_discount = "1";
endif;
// Flag for invoice text mode
if ($f_cs_invtext_mode == "" || count($f_cs_invtext_mode) == 0) :
$f_cs_invtext_mode = "0";
else:
$f_cs_invtext_mode = "1";
endif;
// Flag for no longhaul
if ($f_cmp_no_longhaul == "" || count($f_cmp_no_longhaul) == 0) :
$f_cmp_no_longhaul = "0";
else:
$f_cmp_no_longhaul = "1";
endif;
// Flag for (fuel) markup
if ($f_cs_markup == "" || count($f_cs_markup) == 0) :
$f_cs_markup = "0";
else:
$f_cs_markup = "1";
endif;
// Flag for customer to create jobs
if ($f_cs_jbedit == "" || count($f_cs_jbedit) == 0) :
$f_cs_jbedit = "0";
else:
$f_cs_jbedit = "1";
endif;
// Flag for customer to create jobs
if ($f_cs_ar == "" || count($f_cs_ar) == 0) :
$f_cs_ar = "0";
else:
$f_cs_ar = "1";
endif;
// Flag for customer to check price has to blink in job list if it is uncomplete
if ($f_cs_price_warn_uncomplete == "" || count($f_cs_price_warn_uncomplete) == 0) :
$f_cs_price_warn_uncomplete = "0";
else:
$f_cs_price_warn_uncomplete = "1";
endif;
// Flag for customer to disable displaying in job lists
if ($f_cs_joblist_disabled == "" || count($f_cs_joblist_disabled) == 0) :
$f_cs_joblist_disabled = "0";
else:
$f_cs_joblist_disabled = "1";
endif;
// Flag for status mail extra fields
if ($f_cs_jbstatusmail_field1 == "" || count($f_cs_jbstatusmail_field1) == 0) :
$f_cs_jbstatusmail_field1 = "0";
else:
$f_cs_jbstatusmail_field1 = "1";
endif;
if ($f_cs_jbstatusmail_field2 == "" || count($f_cs_jbstatusmail_field2) == 0) :
$f_cs_jbstatusmail_field2 = "0";
else:
$f_cs_jbstatusmail_field2 = "1";
endif;
if ($f_cs_jbstatusmail_field3 == "" || count($f_cs_jbstatusmail_field3) == 0) :
$f_cs_jbstatusmail_field3 = getParameterValue("0", "CS_JBSTATUSMAIL_FIELD3_DEFAULT", $hq_id);
else:
$f_cs_jbstatusmail_field3 = "1";
endif;
if ($f_cs_jbstatusmail_field4 == "" || count($f_cs_jbstatusmail_field4) == 0) :
$f_cs_jbstatusmail_field4 = "0";
else:
$f_cs_jbstatusmail_field4 = "1";
endif;
if ($f_cs_jbstatusmail_field5 == "" || count($f_cs_jbstatusmail_field5) == 0) :
$f_cs_jbstatusmail_field5 = "0";
else:
$f_cs_jbstatusmail_field5 = "1";
endif;
if ($f_cs_jbstatusmail_field6 == "" || count($f_cs_jbstatusmail_field6) == 0) :
$f_cs_jbstatusmail_field6 = "0";
else:
$f_cs_jbstatusmail_field6 = "1";
endif;
if ($f_cs_jbstatusmail_field7 == "" || count($f_cs_jbstatusmail_field7) == 0) :
$f_cs_jbstatusmail_field7 = "0";
else:
$f_cs_jbstatusmail_field7 = "1";
endif;
if ($f_cs_jbstatusmail_field8 == "" || count($f_cs_jbstatusmail_field8) == 0) :
$f_cs_jbstatusmail_field8 = "0";
else:
$f_cs_jbstatusmail_field8 = "1";
endif;
if ($f_cs_jbstatusmail_field9 == "" || count($f_cs_jbstatusmail_field9) == 0) :
$f_cs_jbstatusmail_field9 = getParameterValue("0", "CS_JBSTATUSMAIL_FIELD9_DEFAULT", $hq_id);
else:
$f_cs_jbstatusmail_field9 = "1";
endif;
if ($f_cs_jbstatusmail_fieldA == "" || count($f_cs_jbstatusmail_fieldA) == 0) :
$f_cs_jbstatusmail_fieldA = getParameterValue("0", "CS_JBSTATUSMAIL_FIELDA_DEFAULT", $hq_id);
else:
$f_cs_jbstatusmail_fieldA = "1";
endif;
$f_cs_jbstatusmail_fields = $f_cs_jbstatusmail_field1 . $f_cs_jbstatusmail_field2 . $f_cs_jbstatusmail_field3 . $f_cs_jbstatusmail_field4 . $f_cs_jbstatusmail_field5 . $f_cs_jbstatusmail_field6 . $f_cs_jbstatusmail_field7 . $f_cs_jbstatusmail_field8 . $f_cs_jbstatusmail_field9 . $f_cs_jbstatusmail_fieldA;
// Job jam waittime default value (in minutes)
$parCsJbJamWaittimeAdHocDefault = getParameterValue("0", "CS_JB_JAM_WAITTIME_AD_HOC_DEFAULT", $hq_id);
if ($parCsJbJamWaittimeAdHocDefault == "") : $parCsJbJamWaittimeAdHocDefault = getParameterValue("0", "CS_JB_JAM_WAITTIME_AD_HOC_DEFAULT", "0"); endif;
$parCsJbJamWaittimeReservationDefault = getParameterValue("0", "CS_JB_JAM_WAITTIME_RESERVATION_DEFAULT", $hq_id);
if ($parCsJbJamWaittimeReservationDefault == "") : $parCsJbJamWaittimeReservationDefault = getParameterValue("0", "CS_JB_JAM_WAITTIME_RESERVATION_DEFAULT", "0"); endif;
// Customer job jam waittime
if ($f_cs_jb_jam_waittime == "" || count($f_cs_jb_jam_waittime) == 0) :
$f_cs_jb_jam_waittime = 0;
else :
if ($companyId != "") :
$f_cs_jb_jam_waittime = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_jb_jam_waittime");
endif;
if (!is_numeric($f_cs_jb_jam_waittime) || $f_cs_jb_jam_waittime == "0") :
$f_cs_jb_jam_waittime = $parCsJbJamWaittimeAdHocDefault;
endif;
endif;
// Init
if ($f_cmp_sales_ranking_man == "") : $f_cmp_sales_ranking_man = "0"; endif;
if ($f_cmp_proof_delivery == "") : $f_cmp_proof_delivery = "0"; endif;
if ($f_cs_payment_term == "") : $f_cs_payment_term = "0"; endif;
mcIsSet($cs_id_new); mcIsSet($cmpId); mcIsSet($eid); mcIsSet($usrName); mcIsSet($usrFirstname); mcIsSet($adStreet); mcIsSet($cmpHsno);
mcIsSet($adZipcode); mcIsSet($adCity); mcIsSet($oldDpfChecksum); mcIsSet($phpCurrentNavigationInputHidden); mcIsSet($adCity);
// Photos
if ($f_cs_photo_disabled == "") :
$f_cs_photo_disabled = "0";
else:
$f_cs_photo_disabled = "1";
endif;
if ($f_cs_photo_hq == "") :
$f_cs_photo_hq = "0";
else:
$f_cs_photo_hq = "1";
endif;
if ($f_cs_photo_cs == "") :
$f_cs_photo_cs = "0";
else:
$f_cs_photo_cs = "1";
endif;
if ($f_cs_photo_range_from == "") :
$f_cs_photo_range_from = "0";
endif;
if ($f_cs_photo_range_to == "") :
$f_cs_photo_range_to = "0";
endif;
// Init parameter for executing the personal embargo request
$execEmbargoCheck = "0";
// Change costcenter addresses according to the main address
$changeBeneficiaryAddress = FALSE;
$changeInvoiceAddress = FALSE;
$changePickUpAddress = FALSE;
if ($f_adt_change != "") :
if (!(array_search("1",$f_adt_change) === FALSE)) : $changeBeneficiaryAddress = TRUE; endif;
if (!(array_search("2",$f_adt_change) === FALSE)) : $changeInvoiceAddress = TRUE; endif;
if (!(array_search("4",$f_adt_change) === FALSE)) : $changePickUpAddress = TRUE; endif;
endif;
// Change costcenter company names according to the main name
$changeBeneficiaryCompany = FALSE;
$changeInvoiceCompany = FALSE;
$changePickUpCompany = FALSE;
if ($f_adt_change2 != "") :
if (!(array_search("1",$f_adt_change2) === FALSE)) : $changeBeneficiaryCompany = TRUE; endif;
if (!(array_search("2",$f_adt_change2) === FALSE)) : $changeInvoiceCompany = TRUE; endif;
if (!(array_search("4",$f_adt_change2) === FALSE)) : $changePickUpCompany = TRUE; endif;
endif;
// Check for minimum length of phone numbers
$parCsPhoneMinLength = getParameterValue("0", "CS_PHONE_MINIMUM_LENGTH", $hq_id);
if ($parCsPhoneMinLength == "") : $parCsPhoneMinLength = getParameterValue("0", "CS_PHONE_MINIMUM_LENGTH", "0"); endif;
// Get mask parameter regarding change behaviour of the tax field
$parMaskCsTaxIdsChangeMsg = getParameterValue("0", "MASK_CS_SPECIAL_TAX_IDS_CHANGE_MSG", $hq_id);
if ($parMaskCsTaxIdsChangeMsg == "") : $parMaskCsTaxIdsChangeMsg = getParameterValue("0", "MASK_CS_SPECIAL_TAX_IDS_CHANGE_MSG", "0"); endif;
if ($parMaskCsTaxIdsChangeMsg != "") : $parMaskCsTaxIdsChangeMsg = "'" . implode("','", spliti(",", $parMaskCsTaxIdsChangeMsg)) . "'"; endif;
// Get mandatory fields to be checked
$parMaskMandatoryFields = getMandatoryFields("MASK_CS_MANDATORY_FIELDS");
$parMaskMandatoryFieldsLen = count($parMaskMandatoryFields);
// Check tracking functionality enabled
$parCsTracking = getParameterValue("0", "CS_TRACKING_ENABLED", $hq_id);
if ($parCsTracking == "") : $parCsTracking = getParameterValue("0", "CS_TRACKING_ENABLED", "0"); endif;
// Get EID prefix and reset EID only if equals prefix
$constCsEidPrefix = getParameterValue("0", "CS_EID_PREFIX", $hq_id);
if ($f_cs_eid == $constCsEidPrefix) : $f_cs_eid = ""; endif;
// ONLY for transformation from "prospect'"' to "customer" !!!
// ***
if ($pt2cs != "") :
// Get max-value of the EID of the current customer for inserting a new row
// The constant value "CS_EID_GENERATION" contains the prefix of the SID [SPECIAL TREATMENT]
$f_eid_maxval = "";
// $csEidGeneration = getParameterValue("0", "CS_EID_GENERATION");
if (CS_EID_GENERATION != "") :
$f_eid_maxval = getMaxOfField("customer", "cs_eid", "cs_eid < '" . CS_EID_GENERATION . "'");
if (is_numeric($f_eid_maxval)) :
++$f_eid_maxval; // Increment because of the next free EID (Attention: Not TA-safe!)
else :
// Remove alphanumeric chars (e.g "HTHB123456" => "123456")
$prefixChars = ereg_replace("[^[:alpha:]+]","",$f_eid_maxval);
$f_eid_maxval = ereg_replace("[^[:digit:]+]","",$f_eid_maxval);
++$f_eid_maxval;
$f_eid_maxval = $prefixChars . $f_eid_maxval;
endif;
$f_cs_eid = $f_eid_maxval; // !!!
endif;
endif;
// *******
// ********************************
// * Operations for the customers *
// ********************************
// Generate log string
if ($f_act != "") :
$f_cmp_comp = str_replace("'", "", $f_cmp_comp);
$f_cmp_comp2 = str_replace("'", "", $f_cmp_comp2);
$f_cmp_comp3 = str_replace("'", "", $f_cmp_comp3);
$f_cmp_comp4 = str_replace("'", "", $f_cmp_comp4);
$f_cmp_match = str_replace("'", "", $f_cmp_match);
$f_cmp_match2 = str_replace("'", "", $f_cmp_match2);
$f_cmp_remark = str_replace("'", "´", $f_cmp_remark);
$f_cmp_remark2 = str_replace("'", "´", $f_cmp_remark2);
$logString = makeLogString(array($f_cmp_authenticated,$f_cmp_comp,$f_cmp_comp2,$f_cs_eid,$f_usr_name,
$f_usr_firstname,$f_usr_phone,$f_usr_phone2,$f_usr_fax,$f_usr_email,$f_cmp_iln,
$f_cmp_tax_idno,$f_cs_invmode,$f_cmp_bank,$f_cmp_bankno,$f_cmp_bankacc,
$f_cmp_bankmode,$f_cs_discount,$f_cmp_postage,$f_cmp_inv2hq,$f_usr_account,
$f_cs_jbstatusmail,$f_cs_commission_no,$f_cs_cr_fav_only,$f_cs_jobbatch,
$f_cmp_cashmode,$f_cmp_visible,$f_ad_changemode,$f_adt_change,$f_cmp_changemode,
$f_adt_change2,$f_ad_street,$f_cmp_hsno,$f_ad_zipcode,$f_ad_city,$f_ad_country,
$f_cmp_match,$f_cmp_match2,$g_cs_id,$g_csc_id,$g_tx_id,$g_br_id,$g2_cs_id,
$f_cs_fixprice_discount,$f_cs_jbstatusmail2,$f_cs_jbstatusmail3,
$f_cs_invtext_mode, $f_cs_prov, $f_cmp_remark,$f_cmp_remark2,$f_cs_markup,
$f_cs_markup_prov, $f_cs_jbstatusmail2csc, $f_cs_jbedit, $f_cs_jbstatusmail_price,
$f_cs_jbstatusmail_emp, $f_cs_jbstatusmail_pdf, $f_cs_jbstatusmail_fields,
$f_cmp_stax_idno, $f_cmp_iban, $f_cmp_swift, $f_cmp_hqlino, $f_cmp_type, $f_cmp_newsletter,
$f_cs_price_warn_uncomplete, $g_sales_emp_id, $f_cmp_sales_ranking_man,$f_cmp_comp3,$f_cmp_comp4,
$f_cmp_proof_delivery, $f_cmp_pda_usage, $f_cs_tracking, $f_cmp_dsgvo, $f_cs_joblist_disabled,
$f_cs_eid_old, $f_cs_jb_jam_waittime, $f_usr_inv_email, $f_cs_ar, $f_cs_charging_time,
$f_cs_blur_markup_time, $f_cmp_sustainability_email, $f_cmp_sustainability_interval,
$f_cs_photo_disabled, $f_cs_photo_hq, $f_cs_photo_cs, $f_cs_photo_range_from, $f_cs_photo_range_to,
$f_cmp_no_longhaul, $f_cs_payment_term, $f_cs_par_email_arrivaltime, $f_cs_par_email_lng,
$f_cs_jb_creator_discount, $f_cs_jb_incomplete, $f_cs_jb_jam_waittime_minutes, $f_usr_reminder_email,
$f_cmp_gln), ";", "0");
endif;
// Insert new customer
if ($f_act == "newCustomer") :
if ($f_cmp_comp != "" && $f_cs_eid != "" && $f_usr_phone != "" && $f_ad_street != "" && $f_ad_zipcode != "" && $f_ad_city != "" && $f_cmp_hsno != "" && ($csCurrIsCashPayer == "1" || ($f_usr_inv_email != "" && $f_usr_reminder_email != ""))) :
// $f_usr_name != "" && $f_usr_firstname != "" &&
// Check unique account for all customers (all data) except the current one to be updated
if ($f_usr_account != "" && $db->getOne("SELECT usr.usr_id FROM user AS usr WHERE usr.usr_account = '" . $f_usr_account . "' ")) :
$statusMessage = getLngt("Der Benutzername existiert schon! Bitte wählen Sie einen anderen!");
elseif (FALSE && $db->getOne("SELECT cmp_comp FROM company WHERE cmp_comp = '" . $f_cmp_comp . "'")) :
$statusMessage = getLngt("Der Firmenname ist bereits vorhanden! Bitte wählen Sie einen anderen!");
elseif ($db->getOne("SELECT cs_eid FROM customer WHERE cs_eid = '" . $f_cs_eid . "'")) :
$statusMessage = getLngt("Die eindeutige Kundennummer (ExtID) ist bereits vergeben! Bitte wählen Sie eine andere");
// The account and password can be empty (only for customer)
elseif ($f_usr_password == "" || checkPasswordValidation($f_usr_password,$f_usr_password2)) :
// Check address for validation
$addressValid = getGeoCoordinates($f_ad_street, $f_ad_zipcode, $f_ad_city, $f_cmp_hsno, $f_ad_country, "");
if ($addressValid != "") :
// Check zipcode and city
$addressValidityArray = checkCityZipcode($f_ad_zipcode, $f_ad_city, $f_ad_street);
if ($noValidationOfAddress || $addressValidityArray[0] >= 1) :
$currentTime = getDateTime("0");
// Execute INSERT operations
$insertOk = insertCustomer();
if ($insertOk) :
// Write into "servicepricehistory"
insertStmt("servicepricehistory", array("srvprch_obj_type","cs", "srvprch_obj_id", $cs_id_new, "srvprch_fieldname", "cs_discount", "srvprch_price", $f_cs_discount, "srvprch_validfrom", $currentTime));
insertStmt("servicepricehistory", array("srvprch_obj_type","cs", "srvprch_obj_id", $cs_id_new, "srvprch_fieldname", "cs_prov", "srvprch_price", $f_cs_prov, "srvprch_validfrom", $currentTime));
insertStmt("servicepricehistory", array("srvprch_obj_type","cs", "srvprch_obj_id", $cs_id_new, "srvprch_fieldname", "cs_markup_prov", "srvprch_price", $f_cs_markup_prov, "srvprch_validfrom", $currentTime));
// ********** DPF **********
// Reset fields of form-parameters
// clearParameters($httpVisualVars); // <= Moved to the end of the php-part of this script...
$dbOperationCompleted = "1";
// Check according to personal embargo
// (NOT included in transaction)
$constDPFCustomerEnabled = getParameterValue("0", "DPF_CS_ENABLED", "0"); // "Meta-Global" <=> hq_id = 0
if ($constDPFCustomerEnabled == '1') :
$execEmbargoCheck = "1";
$cmpId = $cmp_id_new;
$eid = $f_cs_eid;
$usrName = $f_usr_name;
$usrFirstname = $f_usr_firstname;
$adStreet = $f_ad_street;
$cmpHsno = $f_cmp_hsno;
$adZipcode = $f_ad_zipcode;
$adCity = $f_ad_city;
// = $f_ad_country;
// Check for DPF checksum
$oldDpfChecksum = "";
$newDpfChecksum = md5($usrFirstname . $usrName . $adStreet . $cmpHsno . $adZipcode . $adCity);
updateStmt("company", "cmp_id", $cmp_id_new, array("cmp_dpf_checksum", $newDpfChecksum));
endif;
// ********** HASH **********
// Check for execute functionality
if ($GLOBAL_USAGE_HASH) :
// Get current global number of THIS database instance
$constGlobalDbInstNo = getParameterValue("0", "GLOBAL_UNIQUE_DB_INSTANCE_NO", "0", "0");
if ($constGlobalDbInstNo != "" && is_numeric($constGlobalDbInstNo)) :
// Generate unique hash value e.g. for newsletter
$tmpHash = makeMD5Hash($hq_id, $cs_id_new, $currentTime);
// Get database instance connection data of metaobject
$constExtDbInst = getExternalMetaDbInst();
$db_conn = getDbConnectionSpecial($constExtDbInst, $dbname, $dblogin, $dbpassword);
$tmpSqlQuery = "INSERT meta_object.metaobject (mo_id_ref_db,mo_mnemonic,mo_name,mo_obj_type,mo_obj_id,mo_hash) VALUES ('" . $constGlobalDbInstNo . "','','','cs','" . $cs_id_new . "','" . $tmpHash . "') ";
$result = $db_conn->dbQuery($tmpSqlQuery);
$err = "";
if (DB::isError($result)) {$err = "ERR";};
if ($err == "ERR") :
// Send info mail
sendInternalMail("customer_hash_generation_failed_in_metaobjects: CS_ID=" . $cs_id_new . "|CS_EID=" . $f_cs_eid);
endif;
endif;
endif;
// ********** GDC **********
// Old EID
$f_cs_eid_old = trim($f_cs_eid_old);
if ($f_cs_eid_old != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "cs", "gdc_obj_id", $cs_id_new, "gdc_gen_fieldname", "eid_old", "gdc_content", $f_cs_eid_old, "gdc_context", $currentTime));
endif;
// ********** PARAMETER **********
// Flag for configuration regarding "display station number"
if (mcChkValOrArrCountIsEmpty($f_cs_par_tr_sort)) :
$f_cs_par_tr_sort = "0";
else:
$f_cs_par_tr_sort = "1";
endif;
setParameterValue("JOBDETAILS_STATIONS_STATION_NUMBER_" . $cs_id_new, $f_cs_par_tr_sort);
// Flag for color of the jobs in job lists
if (mcChkValOrArrCountIsEmpty($f_cs_par_order_color)) :
$f_cs_par_order_color = "FFFFFF";
endif;
if ($f_cs_par_order_color != "FFFFFF") :
setParameterValue("JOBLIST_CS_JB_COLOR_" . $cs_id_new, $f_cs_par_order_color);
endif;
// Flag for NOT displaying jobs in job lists
if (mcChkValOrArrCountIsEmpty($f_cs_par_xxxxxxxx)) :
$f_cs_par_xxxxxxxx = "0";
else:
$f_cs_par_xxxxxxxx = "1";
endif;
setParameterValue("CUSTOMER_MASK_JOBLIST_XXXXXXXXXX_" . $cs_id_new, $f_cs_par_xxxxxxxx);
// Flag for job cancellation by customer
if (mcChkValOrArrCountIsEmpty($f_cs_jb_storno)) :
$f_cs_jb_storno = "0";
else:
$f_cs_jb_storno = "1";
endif;
setParameterValue("CUSTOMER_MASK_JOBLIST_CANCELLATION_ENABLED_" . $cs_id_new, $f_cs_jb_storno);
// Flag for job disposition to favoured couriers by customer
if (mcChkValOrArrCountIsEmpty($f_cs_jb_dispo)) :
$f_cs_jb_dispo = "0";
else:
$f_cs_jb_dispo = "1";
endif;
setParameterValue("CUSTOMER_MASK_JOBLIST_DISPO_FAV_ENABLED_" . $cs_id_new, $f_cs_jb_dispo);
// Flag for making standard price in customer login
// if ($f_cs_par_dont_make == "" || count($f_cs_par_dont_make) == 0) :
if (mcChkValOrArrCountIsEmpty($f_cs_par_dont_make)) :
$f_cs_par_dont_make = "0";
else:
$f_cs_par_dont_make = "1";
endif;
setParameterValue("MASK_CS_DONT_MAKE_STANDARD_PRICE_" . $cs_id_new, $f_cs_par_dont_make);
// Flag for calculator has to be a must for jobs of the customer
// if ($f_cs_par_calc_usage == "" || count($f_cs_par_calc_usage) == 0) :
if (mcChkValOrArrCountIsEmpty($f_cs_par_calc_usage)) :
$f_cs_par_calc_usage = "0";
else:
$f_cs_par_calc_usage = "1";
endif;
setParameterValue("CUSTOMER_MASK_CALCULATOR_USAGE_ONLY_" . $cs_id_new, $f_cs_par_calc_usage);
// Flag for not checking address in KAE
if ($f_cs_par_cst_all_ad == "" || count($f_cs_par_cst_all_ad) == 0) :
$f_cs_par_cst_all_ad = "0";
else:
$f_cs_par_cst_all_ad = "1";
endif;
setParameterValue("MASK_CUST_ALL_ADDR_ENABLED_" . $cs_id_new, $f_cs_par_cst_all_ad);
// Flag for emails to avoid sending the footer
if (mcChkValOrArrCountIsEmpty($f_cs_par_email_no_footer)) :
$f_cs_par_email_no_footer = "0";
else:
$f_cs_par_email_no_footer = "1";
endif;
setParameterValue("JOBDETAILS_EMAIL_NO_FOOTER_" . $cs_id_new, $f_cs_par_email_no_footer);
// Flag for customer to get a discount by self-creating jobs
if (mcChkValOrArrCountIsEmpty($f_cs_jb_creator_discount)) :
$f_cs_jb_creator_discount = "0";
else:
$f_cs_jb_creator_discount = "1";
endif;
setParameterValue("CUSTOMER_MASK_JB_CREATOR_DISCOUNT_" . $cs_id_new, $f_cs_jb_creator_discount);
// Email arrival time
if ($f_cs_par_email_arrivaltime != "" && is_numeric($f_cs_par_email_arrivaltime)) :
// Check existence of parameter entry to avoid a parameter for each (new) customer if no arrivaltime will be displayed (!!!!)
$tmpEmailArrTime = getParameterValue("0", "JOB_MAIL_STATION_ARRIVAL_TIME_" . $cs_id_new, "0");
if ($f_cs_par_email_arrivaltime != "0" || $tmpEmailArrTime != "") :
setParameterValue("JOB_MAIL_STATION_ARRIVAL_TIME_" . $cs_id_new, $f_cs_par_email_arrivaltime);
endif;
endif;
// Email language
if ($f_cs_par_email_lng != "" && is_numeric($f_cs_par_email_lng)) :
// Check existence of parameter entry to avoid a parameter for each (new) customer if language is default language (!!!!)
$tmpEmailLng = getParameterValue("0", "JOBDETAILS_EMAIL_LANGUAGE_" . $cs_id_new, "0");
if ($f_cs_par_email_lng != "0" || $tmpEmailLng != "") :
setParameterValue("JOBDETAILS_EMAIL_LANGUAGE_" . $cs_id_new, $f_cs_par_email_lng);
endif;
endif;
// Flag for customer to set job being incomplete by creating or modifying a job
if (mcChkValOrArrCountIsEmpty($f_cs_jb_incomplete)) :
$f_cs_jb_incomplete = "0";
else:
$f_cs_jb_incomplete = "1";
endif;
setParameterValue("CUSTOMER_MASK_JB_INCOMPLETE_" . $cs_id_new, $f_cs_jb_incomplete);
// Photos
setCsPhotoConf($cs_id_new, $f_cs_photo_disabled, $f_cs_photo_hq, $f_cs_photo_cs, $f_cs_photo_range_from, $f_cs_photo_range_to);
else :
$statusMessage = getLngt("Der Kundendatensatz wurde nicht angelegt!");
endif;
else :
$statusMessage = getLngt("Die Postleitzahl bzw. Strasse passt nicht zu dem angegebenen Ort!");
$addressValidationErr = "1";
endif;
else :
$statusMessage = getLngt("Der Adress-Server kennt die eingebene Adresse nicht oder besitzt keine Geocodierung!");
endif;
endif;
else :
$statusMessage = getLngt("Bitte geben Sie alle mit * gekennzeichneten Felder ein!");
endif;
endif;
// Modify customer
if ($f_act == "modifyCustomer" && $companyId != "") :
// Check customer to be modified is authenticated because of mandatory field
$v_cmp_authenticated = getFieldValueFromId("company", "cmp_id", $companyId, "cmp_authenticated");
if ($f_cmp_comp != "" && $f_cs_eid != "" && $f_usr_phone != "" && $f_ad_street != "" && $f_ad_zipcode != "" && $f_ad_city != "" && $f_cmp_hsno != "" && ($v_cmp_authenticated != "1" || $csCurrIsCashPayer == "1" || ($f_usr_inv_email != "" && $f_usr_reminder_email != ""))) :
// $f_usr_name != "" && $f_usr_firstname != "" &&
if ($f_usr_account != "" &&
$db->getOne("SELECT usr.usr_id FROM user AS usr " .
" WHERE usr.usr_account = '" . $f_usr_account . "' AND " .
" usr.usr_id != $f_usr_id")) :
$statusMessage = getLngt("Der Benutzername existiert schon! Bitte wählen Sie einen anderen!");
else :
if (trim($f_usr_account) == "" || $cpfs == "0" || ($cpfs == "1" && trim($f_usr_account) != "" && checkPasswordValidation($f_usr_password,$f_usr_password2))) :
$sqlquery = "SELECT cs.cs_id, emp.emp_id, usr.usr_id, cs.csc_id"
. " FROM user AS usr, employee AS emp, customer AS cs, company AS cmp"
. " WHERE cmp.cmp_id = " . $companyId
. " AND cs.cmp_id = cmp.cmp_id"
. " AND emp.emp_id = cs.cs_admin"
. " AND usr.usr_id = emp.usr_id";
$result = $db->dbQ($sqlquery);
while ($row = $result->fetch_assoc()):
$v_cs_id = $row["cs_id"];
$v_emp_id = $row["emp_id"];
$v_usr_id = $row["usr_id"];
$v_csc_id = $row["csc_id"];
endwhile;
$result->free();
if ($v_cs_id != "" && $v_emp_id != "" && $v_usr_id != "" && $v_csc_id != "") :
if ($db->getOne("SELECT cs_eid FROM customer WHERE cs_eid = '" . $f_cs_eid . "' AND "
. " NOT (cs_id = '" . $v_cs_id . "')")) :
$statusMessage = getLngt("Die eindeutige Kundennummer (ExtID) ist bereits vergeben! Bitte wählen Sie eine andere");
else :
$addressValid = getGeoCoordinates($f_ad_street, $f_ad_zipcode, $f_ad_city, $f_cmp_hsno, $f_ad_country, "");
if ($addressValid != "") :
// Check zipcode and city
$addressValidityArray = checkCityZipcode($f_ad_zipcode, $f_ad_city, $f_ad_street);
if ($noValidationOfAddress || $addressValidityArray[0] >= 1) :
TA("B");
$currentTime = getDateTime("0");
// Get current price values from "servicepricehistory"
$csPriceFieldsCurrent = getFieldsValueFromId("customer", "cs_id", $v_cs_id, array("cs_discount","cs_prov","cs_markup_prov"));
// Get current state in cmp_modify_status because it is equal to "1" then do NOT change
$modifyStatus = getFieldValueFromId("company", "cmp_id", $companyId, "cmp_modify_status");
if ($modifyStatus != "1") : $modifyStatus = "2"; endif;
// Update company
$f_cmp_postage = str_replace (",", ".", $f_cmp_postage);
$defaultFields = array("cmp_type",$f_cmp_type,"cmp_comp",$f_cmp_comp,"cmp_comp2",$f_cmp_comp2,"cmp_comp3",$f_cmp_comp3,"cmp_comp4",$f_cmp_comp4,"cmp_hsno",$f_cmp_hsno,"cmp_iln",$f_cmp_iln,
"cmp_tax_idno",$f_cmp_tax_idno,"cmp_stax_idno",$f_cmp_stax_idno,"tx_id",$g_tx_id,"br_id",$g_br_id,
"emp_id_sales",$g_sales_emp_id,"cmp_sales_ranking_man",$f_cmp_sales_ranking_man,
"cmp_bank",$f_cmp_bank,"cmp_bankno",$f_cmp_bankno,"cmp_bankacc",$f_cmp_bankacc,"cmp_bankmode",$f_cmp_bankmode,
"cmp_iban",$f_cmp_iban,"cmp_swift",$f_cmp_swift,"cmp_hqlino",$f_cmp_hqlino,"cmp_gln",$f_cmp_gln,"cmp_postage",$f_cmp_postage,"cmp_inv2hq",$f_cmp_inv2hq,"cmp_no_longhaul",$f_cmp_no_longhaul,
"cmp_match",$f_cmp_match,"cmp_match2",$f_cmp_match2,"cmp_sustainability_email",$f_cmp_sustainability_email, "cmp_sustainability_interval", $f_cmp_sustainability_interval,
"cmp_remark",$f_cmp_remark,"cmp_remark2",$f_cmp_remark2, "cmp_dsgvo", $f_cmp_dsgvo,
"cmp_newsletter",$f_cmp_newsletter,"cmp_proof_delivery",$f_cmp_proof_delivery,"cmp_pda_usage", $f_cmp_pda_usage,"cmp_modify_status", $modifyStatus);
updateStmt("company","cmp_id",$companyId,$defaultFields);
// Update customer
$f_cs_discount = str_replace (",", ".", $f_cs_discount);
$f_cs_prov = str_replace (",", ".", $f_cs_prov);
$f_cs_markup_prov = str_replace (",", ".", $f_cs_markup_prov);
$defaultFields = array("cs_eid",$f_cs_eid,"csc_id_payer",$g_csc_id,"cs_id_parent",$g2_cs_id,"cs_discount",$f_cs_discount,"cs_invmode",$f_cs_invmode,"cs_jbstatusmail2csc",$f_cs_jbstatusmail2csc,"cs_jbstatusmail_price", $f_cs_jbstatusmail_price,"cs_jbstatusmail_emp",$f_cs_jbstatusmail_emp,"cs_jbstatusmail_pdf",$f_cs_jbstatusmail_pdf,"cs_jbstatusmail_fields",$f_cs_jbstatusmail_fields,"cs_jbstatusmail",$f_cs_jbstatusmail,"cs_jbstatusmail2",$f_cs_jbstatusmail2,"cs_jbstatusmail3",$f_cs_jbstatusmail3,"cs_jb_jam_waittime",$f_cs_jb_jam_waittime,"cs_jb_jam_waittime_minutes",$f_cs_jb_jam_waittime_minutes,"cs_commission_no",$f_cs_commission_no,"cs_cr_fav_only",$f_cs_cr_fav_only,"cs_jobbatch",$f_cs_jobbatch,"cs_jbedit",$f_cs_jbedit,"cs_ar",$f_cs_ar,"cs_invtext_mode",$f_cs_invtext_mode,"cs_fixprice_discount",$f_cs_fixprice_discount,"cs_prov",$f_cs_prov,"cs_markup",$f_cs_markup, "cs_markup_prov", $f_cs_markup_prov, "cs_price_warn_uncomplete", $f_cs_price_warn_uncomplete, "cs_joblist_disabled", $f_cs_joblist_disabled, "cs_charging_time", $f_cs_charging_time, "cs_blur_markup_time", $f_cs_blur_markup_time, "cs_payment_term", $f_cs_payment_term);
updateStmt("customer","cs_id",$v_cs_id,$defaultFields);
// Update user
$defaultFields = array("usr_name",$f_usr_name,"usr_firstname",$f_usr_firstname,"usr_email",$f_usr_email,"usr_inv_email",$f_usr_inv_email,"usr_reminder_email",$f_usr_reminder_email,"usr_phone",$f_usr_phone,"usr_phone2",$f_usr_phone2,"usr_fax",$f_usr_fax,"usr_account",$f_usr_account);
updateStmt("user","usr_id",$v_usr_id,$defaultFields);
// Update user, only password-field
if ($cpfs == "1") :
$sqlStmtPwd = "UPDATE user SET usr_password = PASSWORD('" . $f_usr_password . "'), usr_password_modify = '" . $currentTime . "' WHERE usr_id = '" . $v_usr_id . "'";
$res = $db->query($sqlStmtPwd);
if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif;
endif;
if (trim($f_usr_account) == "") :
$sqlStmtPwd = "UPDATE user SET usr_password = '' WHERE usr_id = '" . $v_usr_id . "'";
$res = $db->query($sqlStmtPwd);
if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif;
endif;
// Insert address
$tmpArray = insertAddress($f_ad_street, $f_ad_zipcode, $f_ad_city, "", $f_ad_country, $noValidationOfAddress);
$ad_id_new = $tmpArray[0];
// Update (the new) company-entry with address-id
updateStmt("company", "cmp_id", $companyId, array("ad_id", $ad_id_new));
// * Perhaps also change the name of the root-costcenter! But think of changing all
// * path-entries, too!!! PRESENTLY IT IS NOT NECESSARY TO IMPLEMENT!
// Update costcenter
// $defaultFields = array("csc_name",$f_cmp_comp);
// updateStmt("costcenter","csc_id",$v_csc_id,$defaultFields);
// Update costcenter addresses if requested
// Only root costcenter addresses
if ($f_ad_changemode == "1") :
if ($changeBeneficiaryAddress) :
updateStmt("costcenteraddress","csc_id",$v_csc_id,array("ad_id", $ad_id_new, "cscad_hsno", $f_cmp_hsno),"adt_id = 1");
endif;
if ($changeInvoiceAddress) :
updateStmt("costcenteraddress","csc_id",$v_csc_id,array("ad_id", $ad_id_new, "cscad_hsno", $f_cmp_hsno),"adt_id = 2");
endif;
if ($changePickUpAddress) :
updateStmt("costcenteraddress","csc_id",$v_csc_id,array("ad_id", $ad_id_new, "cscad_hsno", $f_cmp_hsno),"adt_id = 4");
endif;
endif;
// ALL costcenter addresses
if ($f_ad_changemode == "2") :
// First get all costcenters of the current customer
$sqlquery = "SELECT csc.csc_id FROM costcenter AS csc WHERE csc.cs_id = " . $v_cs_id;
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
$cscIdArray = array();
while ($row = $result->fetch_assoc()):
$cscIdArray[] = $row["csc_id"];
endwhile;
$result->free();
if (count($cscIdArray) > 0) :
if ($changeBeneficiaryAddress) :
$sqlStmtAdress = "UPDATE costcenteraddress SET ad_id = '" . $ad_id_new . "', cscad_hsno = '" . $f_cmp_hsno . "'"
. " WHERE adt_id = '1' AND csc_id IN (" . implode($cscIdArray, ",") . ")";
$res = $db->query($sqlStmtAdress);
if (DB::isError($res)) die ("$PHP_SELF:
$sqlStmt
" . $res->getMessage());
endif;
if ($changeInvoiceAddress) :
$sqlStmtAdress = "UPDATE costcenteraddress SET ad_id = '" . $ad_id_new . "', cscad_hsno = '" . $f_cmp_hsno . "'"
. " WHERE adt_id = '2' AND csc_id IN (" . implode($cscIdArray, ",") . ")";
$res = $db->query($sqlStmtAdress);
if (DB::isError($res)) die ("$PHP_SELF:
$sqlStmt
" . $res->getMessage());
endif;
if ($changePickUpAddress) :
$sqlStmtAdress = "UPDATE costcenteraddress SET ad_id = '" . $ad_id_new . "', cscad_hsno = '" . $f_cmp_hsno . "'"
. " WHERE adt_id = '4' AND csc_id IN (" . implode($cscIdArray, ",") . ")";
$res = $db->query($sqlStmtAdress);
if (DB::isError($res)) die ("$PHP_SELF:
$sqlStmt
" . $res->getMessage());
endif;
endif;
endif;
// Update costcenter company names if requested
// Only root costcenter company name
if ($f_cmp_changemode == "1") :
if ($changeBeneficiaryCompany) :
updateStmt("costcenteraddress","csc_id",$v_csc_id,array("cscad_comp", $f_cmp_comp, "cscad_comp2", $f_cmp_comp2, "cscad_comp3", $f_cmp_comp3, "cscad_comp4", $f_cmp_comp4),"adt_id = 1");
endif;
if ($changeInvoiceCompany) :
updateStmt("costcenteraddress","csc_id",$v_csc_id,array("cscad_comp", $f_cmp_comp, "cscad_comp2", $f_cmp_comp2, "cscad_comp3", $f_cmp_comp3, "cscad_comp4", $f_cmp_comp4),"adt_id = 2");
endif;
if ($changePickUpCompany) :
updateStmt("costcenteraddress","csc_id",$v_csc_id,array("cscad_comp", $f_cmp_comp, "cscad_comp2", $f_cmp_comp2, "cscad_comp3", $f_cmp_comp3, "cscad_comp4", $f_cmp_comp4),"adt_id = 4");
endif;
endif;
// ALL costcenter addresses
if ($f_cmp_changemode == "2") :
// First get all costcenters of the current customer
$sqlquery = "SELECT csc.csc_id FROM costcenter AS csc WHERE csc.cs_id = " . $v_cs_id;
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
$cscIdArray = array();
while ($row = $result->fetch_assoc()):
$cscIdArray[] = $row["csc_id"];
endwhile;
$result->free();
if (count($cscIdArray) > 0) :
if ($changeBeneficiaryCompany) :
$sqlStmtAdress = "UPDATE costcenteraddress SET cscad_comp = '" . $f_cmp_comp . "', cscad_comp2 = '" . $f_cmp_comp2 . "', cscad_comp3 = '" . $f_cmp_comp3 . "', cscad_comp4 = '" . $f_cmp_comp4 . "'"
. " WHERE adt_id = '1' AND csc_id IN (" . implode($cscIdArray, ",") . ")";
$res = $db->query($sqlStmtAdress);
if (DB::isError($res)) die ("$PHP_SELF:
$sqlStmt
" . $res->getMessage());
endif;
if ($changeInvoiceCompany) :
$sqlStmtAdress = "UPDATE costcenteraddress SET cscad_comp = '" . $f_cmp_comp . "', cscad_comp2 = '" . $f_cmp_comp2 . "', cscad_comp3 = '" . $f_cmp_comp3 . "', cscad_comp4 = '" . $f_cmp_comp4 . "'"
. " WHERE adt_id = '2' AND csc_id IN (" . implode($cscIdArray, ",") . ")";
$res = $db->query($sqlStmtAdress);
if (DB::isError($res)) die ("$PHP_SELF:
$sqlStmt
" . $res->getMessage());
endif;
if ($changePickUpCompany) :
$sqlStmtAdress = "UPDATE costcenteraddress SET cscad_comp = '" . $f_cmp_comp . "', cscad_comp2 = '" . $f_cmp_comp2 . "', cscad_comp3 = '" . $f_cmp_comp3 . "', cscad_comp4 = '" . $f_cmp_comp4 . "'"
. " WHERE adt_id = '4' AND csc_id IN (" . implode($cscIdArray, ",") . ")";
$res = $db->query($sqlStmtAdress);
if (DB::isError($res)) die ("$PHP_SELF:
$sqlStmt
" . $res->getMessage());
endif;
endif;
endif;
// Write logdata into log database
writeToLogDB("36",$hq_id,"",$usr_id,"","",$v_cs_id,"STATUS_MODIFIED=" . $logString);
// Tracking
if ($f_cmp_type != "0") :
$f_cs_tracking = "0"; // Overwrite if state is changed
endif;
updateStmt("customer","cs_id",$v_cs_id,array("cs_tracking", $f_cs_tracking));
// Write to "servicepricehistory"
if ($csPriceFieldsCurrent[0] != $f_cs_discount) :
insertStmt("servicepricehistory", array("srvprch_obj_type","cs", "srvprch_obj_id", $v_cs_id, "srvprch_fieldname", "cs_discount", "srvprch_price", $f_cs_discount, "srvprch_validfrom", $currentTime));
endif;
if ($csPriceFieldsCurrent[1] != $f_cs_prov) :
insertStmt("servicepricehistory", array("srvprch_obj_type","cs", "srvprch_obj_id", $v_cs_id, "srvprch_fieldname", "cs_prov", "srvprch_price", $f_cs_prov, "srvprch_validfrom", $currentTime));
endif;
if ($csPriceFieldsCurrent[2] != $f_cs_markup_prov) :
insertStmt("servicepricehistory", array("srvprch_obj_type","cs", "srvprch_obj_id", $v_cs_id, "srvprch_fieldname", "cs_markup_prov", "srvprch_price", $f_cs_markup_prov, "srvprch_validfrom", $currentTime));
endif;
// Generate report entry
if ($f_cmp_current_type != $f_cmp_type) :
// First get user id of the sales employee created this customer dataset
$usr_id_type = $db->getOne("SELECT usr_id FROM phoenix_log.log WHERE logo_id = 95 AND cs_id = " . $v_cs_id . " AND logo_description LIKE '%|OLD=|%'");
$tmpReportText = getLngt("Änderung in") . " " . $pageTitel;
$tmpRpReportType = getParameterValue("0", "CS_CMPTYPE2RPTYPE_MODIFY", "0");
if ($tmpRpReportType == "") : $tmpRpReportType = "1"; endif;
if ($f_cmp_type == "0") :
$tmpRpReportType = getParameterValue("0", "CS_CMPTYPE2RPTYPE_MODIFY_2", "0");
if ($tmpRpReportType == "") : $tmpRpReportType = "2"; endif;
endif;
insertStmt("phoenix_group.report_process", array("usr_id", $usr_id, "hq_id", $hq_id, "rp_reporttype", $tmpRpReportType, "rp_text", $tmpReportText,
"rp_createtime", $currentTime, "rp_objId", $v_cs_id, "rp_objtype", "cs"));
// Set special date if data row is set to "customer state"
if ($f_cmp_type == "0") :
$currentDate = getDateTime("3");
updateStmt("customer","cs_id",$v_cs_id,array("cs_become_cs_date", $currentDate));
endif;
// Write SALES logdata into log database
writeToLogDB("95",$hq_id,"",$usr_id_type,"","",$v_cs_id,"SRC=cs|OLD=" . $f_cmp_current_type . "|NEW=" . $f_cmp_type);
endif;
$f_cmp_current_type = $f_cmp_type;
TA("C");
TA("E");
$dbOperationCompleted = "1";
// Check according to personal embargo
// (NOT included in transaction)
$constDPFCustomerEnabled = getParameterValue("0", "DPF_CS_ENABLED", "0"); // "Meta-Global" <=> hq_id = 0
if ($constDPFCustomerEnabled == '1') :
$execEmbargoCheck = "1";
$cmpId = $companyId;
$eid = $f_cs_eid;
$usrName = $f_usr_name;
$usrFirstname = $f_usr_firstname;
$adStreet = $f_ad_street;
$cmpHsno = $f_cmp_hsno;
$adZipcode = $f_ad_zipcode;
$adCity = $f_ad_city;
// = $f_ad_country;
// Check for DPF checksum
$oldDpfChecksum = getFieldValueFromId("company", "cmp_id", $companyId, "cmp_dpf_checksum");
$newDpfChecksum = md5($usrFirstname . $usrName . $adStreet . $cmpHsno . $adZipcode . $adCity);
if ($oldDpfChecksum == $newDpfChecksum) :
$execEmbargoCheck = "0";
else :
updateStmt("company", "cmp_id", $companyId, array("cmp_dpf_checksum", $newDpfChecksum));
endif;
endif;
// ********** GDC **********
// Old EID
$tmpCsEidOld = getFieldValueFromClause("genericdatacontainer","gdc_content","gdc_obj_type = 'cs' AND gdc_gen_fieldname = 'eid_old' AND gdc_obj_id = '" . $v_cs_id . "'");
if ($tmpCsEidOld != "" || $f_cs_eid_old != "") :
if (existsEntry("genericdatacontainer", array("gdc_obj_type", "cs", "gdc_gen_fieldname", "eid_old", "gdc_obj_id", $v_cs_id))) :
updateStmt("genericdatacontainer","gdc_obj_type","cs",array("gdc_content", $f_cs_eid_old, "gdc_context", $currentTime),"gdc_obj_id = '" . $v_cs_id . "' AND gdc_gen_fieldname = 'eid_old'");
else :
insertStmt("genericdatacontainer", array("gdc_obj_type", "cs", "gdc_obj_id", $v_cs_id, "gdc_gen_fieldname", "eid_old", "gdc_content", $f_cs_eid_old, "gdc_context", $currentTime));
endif;
endif;
// ********** PARAMETER **********
// Flag for configuration regarding "display station number"
if (mcChkValOrArrCountIsEmpty($f_cs_par_tr_sort)) :
$f_cs_par_tr_sort = "0";
else:
$f_cs_par_tr_sort = "1";
endif;
setParameterValue("JOBDETAILS_STATIONS_STATION_NUMBER_" . $v_cs_id, $f_cs_par_tr_sort);
// Flag for color of the jobs in job lists
if (mcChkValOrArrCountIsEmpty($f_cs_par_order_color)) :
$f_cs_par_order_color = "FFFFFF";
endif;
if ($f_cs_par_order_color != "FFFFFF" || ($f_cs_par_order_color == "FFFFFF" && existsEntry("parameter",array("par_key","JOBLIST_CS_JB_COLOR_" . $v_cs_id)))) :
setParameterValue("JOBLIST_CS_JB_COLOR_" . $v_cs_id, $f_cs_par_order_color);
endif;
// Flag for NOT displaying jobs in job lists
if (mcChkValOrArrCountIsEmpty($f_cs_par_xxxxxxxx)) :
$f_cs_par_xxxxxxxx = "0";
else:
$f_cs_par_xxxxxxxx = "1";
endif;
setParameterValue("CUSTOMER_MASK_JOBLIST_XXXXXXXXXX_" . $v_cs_id, $f_cs_par_xxxxxxxx);
// Flag for job cancellation by customer
if (mcChkValOrArrCountIsEmpty($f_cs_jb_storno)) :
$f_cs_jb_storno = "0";
else:
$f_cs_jb_storno = "1";
endif;
setParameterValue("CUSTOMER_MASK_JOBLIST_CANCELLATION_ENABLED_" . $v_cs_id, $f_cs_jb_storno);
// Flag for job disposition to favoured couriers by customer
if (mcChkValOrArrCountIsEmpty($f_cs_jb_dispo)) :
$f_cs_jb_dispo = "0";
else:
$f_cs_jb_dispo = "1";
endif;
setParameterValue("CUSTOMER_MASK_JOBLIST_DISPO_FAV_ENABLED_" . $v_cs_id, $f_cs_jb_dispo);
// Flag for making standard price in customer login
if (mcChkValOrArrCountIsEmpty($f_cs_par_dont_make)) :
$f_cs_par_dont_make = "0";
else:
$f_cs_par_dont_make = "1";
endif;
setParameterValue("MASK_CS_DONT_MAKE_STANDARD_PRICE_" . $v_cs_id, $f_cs_par_dont_make);
// Flag for calculator has to be a must for jobs of the customer
if (mcChkValOrArrCountIsEmpty($f_cs_par_calc_usage)) :
$f_cs_par_calc_usage = "0";
else:
$f_cs_par_calc_usage = "1";
endif;
setParameterValue("CUSTOMER_MASK_CALCULATOR_USAGE_ONLY_" . $v_cs_id, $f_cs_par_calc_usage);
// Flag for not checking address in KAE
if ($f_cs_par_cst_all_ad == "" || count($f_cs_par_cst_all_ad) == 0) :
$f_cs_par_cst_all_ad = "0";
else:
$f_cs_par_cst_all_ad = "1";
endif;
setParameterValue("MASK_CUST_ALL_ADDR_ENABLED_" . $v_cs_id, $f_cs_par_cst_all_ad);
// Flag for emails to avoid sending the footer
if (mcChkValOrArrCountIsEmpty($f_cs_par_email_no_footer)) :
$f_cs_par_email_no_footer = "0";
else:
$f_cs_par_email_no_footer = "1";
endif;
setParameterValue("JOBDETAILS_EMAIL_NO_FOOTER_" . $v_cs_id, $f_cs_par_email_no_footer);
// Flag for customer to get a discount by self-creating jobs
if (mcChkValOrArrCountIsEmpty($f_cs_jb_creator_discount)) :
$f_cs_jb_creator_discount = "0";
else:
$f_cs_jb_creator_discount = "1";
endif;
setParameterValue("CUSTOMER_MASK_JB_CREATOR_DISCOUNT_" . $v_cs_id, $f_cs_jb_creator_discount);
// Email arrival time
if ($f_cs_par_email_arrivaltime != "" && is_numeric($f_cs_par_email_arrivaltime)) :
// Check existence of parameter entry to avoid a parameter for each (new) customer if no arrivaltime will be displayed (!!!!)
$tmpEmailArrTime = getParameterValue("0", "JOB_MAIL_STATION_ARRIVAL_TIME_" . $v_cs_id, "0");
if ($f_cs_par_email_arrivaltime != "0" || $tmpEmailArrTime != "") :
setParameterValue("JOB_MAIL_STATION_ARRIVAL_TIME_" . $v_cs_id, $f_cs_par_email_arrivaltime);
endif;
endif;
// Email language
if ($f_cs_par_email_lng != "" && is_numeric($f_cs_par_email_lng)) :
// Check existence of parameter entry to avoid a parameter for each (new) if language is default language (!!!!)
$tmpEmailLng = getParameterValue("0", "JOBDETAILS_EMAIL_LANGUAGE_" . $v_cs_id, "0");
if ($f_cs_par_email_lng != "0" || $tmpEmailLng != "") :
setParameterValue("JOBDETAILS_EMAIL_LANGUAGE_" . $v_cs_id, $f_cs_par_email_lng);
endif;
endif;
// Flag for customer to set job being incomplete by creating or modifying a job
if (mcChkValOrArrCountIsEmpty($f_cs_jb_incomplete)) :
$f_cs_jb_incomplete = "0";
else:
$f_cs_jb_incomplete = "1";
endif;
setParameterValue("CUSTOMER_MASK_JB_INCOMPLETE_" . $v_cs_id, $f_cs_jb_incomplete);
// Photos
setCsPhotoConf($v_cs_id, $f_cs_photo_disabled, $f_cs_photo_hq, $f_cs_photo_cs, $f_cs_photo_range_from, $f_cs_photo_range_to);
else :
$statusMessage = getLngt("Die Postleitzahl passt nicht zu dem angegebenen Ort!");
$addressValidationErr = "1";
endif;
else :
$statusMessage = getLngt("Der Adress-Server kennt die eingebene Adresse nicht oder besitzt keine Geocodierung!");
endif;
endif;
else :
$statusMessage = getLngt("Datenfehler! Merken Sie sich bitte den Datensatz und kontaktieren uns!!!");
endif;
endif; // account empty or not empty and checked by passwordcheck
endif;
else :
$statusMessage = getLngt("Bitte geben Sie alle mit * gekennzeichneten Felder ein!");
endif;
endif;
// Delete customer
if ($f_act == "removeCustomer" && $companyId != "") :
if (!existsEntry("company",array("cmp_id",$companyId))) :
// if (getDbFieldValues("employee",array("usr_id"),array("emp_id",$emp_id_act))) :
// TA("B");
// deleteStmt("employee","emp_id = ".$emp_id_act);
// deleteStmt("user","usr_id = ".$usr_id_new);
// // Write logdata into log database
// $v_cs_id = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_id");
// writeToLogDB("42",$hq_id,"",$usr_id,"","",$v_cs_id,"STATUS_DELETED");
// TA("C");
// TA("E");
// else :
// $statusMessage = "Datenfehler! Merken Sie sich bitte den Datensatz und kontaktieren uns!!!";
// endif;
else :
$statusMessage = getLngt("Der Kunde existiert nicht!");
endif;
endif;
// Set status of authentication of the customer
if ($f_act == "setAuthentication") :
// Check for company
if ($companyId != "") :
if (existsEntry("company",array("cmp_id",$companyId))) :
// Check for existing jobs in the future
$futureJobListStr = "";
if ($f_cmp_authenticated != "1") :
$futureJobList = getColVectorFromDB2ArrayByClause("company AS cmp, customer AS cs, costcenter AS csc, job AS jb", "jb.jb_id", "cmp.cmp_id = '" . $companyId . "' AND cmp.cmp_id = cs.cmp_id AND cs.cs_id = csc.cs_id AND csc.csc_id = jb.csc_id_payer AND jb.jb_status != '2' AND jb.jb_finishtime > DATE_SUB(NOW(), INTERVAL 1 MONTH)");
if (count($futureJobList) > 0) :
$futureJobListStr = implode(",", $futureJobList);
endif;
endif;
if ($f_cmp_authenticated == "1" || $futureJobListStr == "") :
// Check in case the courier shall be set free but he/she is noticeable according to embargo check
$currentDPFState = getFieldValueFromId("company", "cmp_id", $companyId, "cmp_dpf_state");
if ($f_cmp_authenticated == "1" && $currentDPFState >= "1" && $currentDPFState <= "9") :
// Update DPF state
// Attention: Description of the states look for "dpf.php"
$newDPFState = $currentDPFState + 10;
updateStmt("company","cmp_id",$companyId,array("cmp_dpf_state",$newDPFState));
endif;
// Update authentication-status
updateStmt("company","cmp_id",$companyId,array("cmp_authenticated",$f_cmp_authenticated));
// Write logdata into log database
$v_cs_id = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_id");
writeToLogDB("38",$hq_id,"",$usr_id,"","",$v_cs_id,"STATUS_AUTHENTICATION=".$f_cmp_authenticated);
else :
$statusMessage = getLngt("Der spezifizierte Kunde kann noch nicht gesperrt werden. Es existieren noch die folgenden zukünftigen Aufträge: " . $futureJobListStr);
endif;
else :
$statusMessage = getLngt("Der spezifizierte Kunde ist nicht im Datenbestand erhalten!");
endif;
else :
$statusMessage = getLngt("Sie haben keinen Kunden spezifiziert!");
endif;
endif;
// Set status of visibility of the customer
if ($f_act == "setVisibility") :
// Check for company
if ($companyId != "") :
if (existsEntry("company",array("cmp_id",$companyId))) :
// Update authentication-status
updateStmt("company","cmp_id",$companyId,array("cmp_visible",$f_cmp_visible));
// Write logdata into log database
$v_cs_id = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_id");
writeToLogDB("40",$hq_id,"",$usr_id,"","",$v_cs_id,"STATUS_VISIBILITY=".$f_cmp_visible);
else :
$statusMessage = getLngt("Der spezifizierte Kunde ist nicht im Datenbestand erhalten!");
endif;
else :
$statusMessage = getLngt("Sie haben keinen Kunden spezifiziert!");
endif;
endif;
// Set status of cash mode of the customer
if ($f_act == "setCashmode") :
// Check for company
if ($companyId != "") :
if (existsEntry("company",array("cmp_id",$companyId))) :
// Update authentication-status
updateStmt("company","cmp_id",$companyId,array("cmp_cashmode",$f_cmp_cashmode));
// Write logdata into log database
$v_cs_id = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_id");
writeToLogDB("44",$hq_id,"",$usr_id,"","",$v_cs_id,"STATUS_CASHMODE=".$f_cmp_cashmode);
else :
$statusMessage = getLngt("Der spezifizierte Kunde ist nicht im Datenbestand erhalten!");
endif;
else :
$statusMessage = getLngt("Sie haben keinen Kunden spezifiziert!");
endif;
endif;
// Set state of completition of all current jobs of the customer
if ($f_act == "setJobCompleteMulti") :
// Check for company
if ($companyId != "") :
if (existsEntry("company",array("cmp_id",$companyId))) :
$v_cs_id = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_id");
// Select all incomplete jobs of the customer to be set to state "complete"
$jbSqlquery = "SELECT jb.jb_id"
. " FROM customer AS cs, costcenter AS csc, job AS jb"
. " WHERE cs.cs_id = '" . $v_cs_id . "' AND cs.cs_id = csc.cs_id AND csc.csc_id = jb.csc_id_payer AND"
. " jb.jb_status = '2' AND jb.cr_sid != '' AND jb.cr_id != '' AND jb.jb_totalprice != 0 AND"
. " vht_id != '0' AND jb.jb_incomplete = '1' AND "
. " (ISNULL(jb.jb_storno) OR jb.jb_storno = '0') AND "
. " jb.jb_finishtime > '" . getDateTime("date_plus_offset", array(-1,0,0), "Y-m-d") . " 00:00:00' AND"
. " (ISNULL(jb.jb_export_time) OR jb.jb_export_time = '0000-00-00 00:00:00')";
$result = $db->query($jbSqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
$tmpJbArray = array();
while ($row = $result->fetch_assoc()):
$tmpJbArray[] = $row["jb_id"];
endwhile;
// Update completition state
$tmpJbString = "";
$tmpJbArrayLen = count($tmpJbArray);
if ($tmpJbArrayLen > 0) :
$tmpJbString = implode(",",$tmpJbArray);
updateStmt("job","","",array("jb_incomplete","0"),"jb_id IN (" . $tmpJbString . ")");
$statusMessage = getLngt("Anzahl der Aufträge: " . $tmpJbArrayLen);
else :
$statusMessage = getLngt("Es wurde kein Auftrag gegriffen und auf fertig gesetzt!");
endif;
// Write logdata into log database
writeToLogDB("94",$hq_id,"",$usr_id,"","",$v_cs_id,"JOBS=".$tmpJbString);
else :
$statusMessage = getLngt("Der spezifizierte Kunde ist nicht im Datenbestand erhalten!");
endif;
else :
$statusMessage = getLngt("Sie haben keinen Kunden spezifiziert!");
endif;
endif;
// Send sustainability report to the customer
if ($f_act == "sendSustainabilityReport") :
// Check for company
if ($companyId != "") :
if (existsEntry("company",array("cmp_id",$companyId))) :
$v_cs_id = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_id");
$csIsMeta = false;
$tmpCsIdsSub = getColVectorFromDB2ArrayByClause("customer", "cs_id", "cs_id_parent = '" . $v_cs_id . "'");
if (count($tmpCsIdsSub) > 0) :
$csIsMeta = true;
endif;
// Call script for (meta-)customer
$path = getAbsoluteSystemPath();
$passwd = "acapella7890";
$cmd = "php " . $path . "/tools/auto_trigger_jobs_sustainability_customer_report.php " . $passwd . " " . ($csIsMeta ? "cs_meta" : "cs") . " " . $v_cs_id . " " . $f_cmp_sustainability_interval . " &";
$cmdOutput = null;
exec($cmd, $cmdOutput);
// print_r($cmdOutput); echo "\n\n";
// Write logdata into log database
writeToLogDB("176",$hq_id,"",$usr_id,"","",$v_cs_id,"EMAIL SENT");
else :
$statusMessage = getLngt("Der spezifizierte Kunde ist nicht im Datenbestand erhalten!");
endif;
else :
$statusMessage = getLngt("Sie haben keinen Kunden spezifiziert!");
endif;
endif;
// Reset 2-FA
if ($f_act == "reset2FACustomer") :
// Check for company
if ($companyId != "") :
if (existsEntry("company",array("cmp_id",$companyId))) :
$v_cs_id = getFieldValueFromId("customer", "cmp_id", $companyId, "cs_id");
$retVal = user2FARemove($v_cs_id, "cs");
$statusMessage = $retVal[1];
else :
$statusMessage = getLngt("Der spezifizierte Kunde ist nicht im Datenbestand erhalten!");
endif;
else :
$statusMessage = getLngt("Sie haben keinen Kunden spezifiziert!");
endif;
endif;
// **********************************
// * Selection of the customer data *
// **********************************
// Gets ALL data from a special customer
getCustomer($companyId);
// Get max-value of the EID of the current customer for inserting a new row
// The constant value "CS_EID_GENERATION" contains the prefix of the SID [SPECIAL TREATMENT]
$f_eid_maxval = "";
// $csEidGeneration = getParameterValue("0", "CS_EID_GENERATION");
if (CS_EID_GENERATION != "") :
$f_eid_maxval = getMaxOfField("customer", "cs_eid", "cs_eid < '" . CS_EID_GENERATION . "'");
if (is_numeric($f_eid_maxval)) :
++$f_eid_maxval; // Increment because of the next free EID (Attention: Not TA-safe!)
else :
// Remove alphanumeric chars (e.g "HTHB123456" => "123456")
$prefixChars = ereg_replace("[^[:alpha:]+]","",$f_eid_maxval);
$f_eid_maxval = ereg_replace("[^[:digit:]+]","",$f_eid_maxval);
++$f_eid_maxval;
$f_eid_maxval = $prefixChars . $f_eid_maxval;
endif;
endif;
// Get number of contacts of the current customer
$numOfContacts = getCountOfTable("metafieldvalue AS mtfv, metafieldcategorykey AS mtfck, metafieldkey AS mtfk",
"mtfv.mtfv_value = '" . $f_cs_id . "' AND mtfck.mtfc_id = '1' AND mtfv.mtfck_id = mtfck.mtfck_id AND mtfk.mtfk_id = mtfck.mtfk_id AND mtfk.mtfk_type = 'co2cs'");
// Check if a copy of the current customer is requested.
// If it is then reset some values
if ($copyCs == "1") :
$companyId = "";
$f_cs_eid = "";
$statusMessage = getLngt("ACHTUNG: Aus Sicherheitsgründen werden ausschließlich Daten des Stammblatts kopiert! Filter, Services, Kostenstellen, etc. sind entsprechend nachträglich zuzuweisen!");
// Special case for third party payer
$constCsCopyNoThirdParty = getParameterValue("0", "CS_COPY_NO_THIRD_PARTY", $hq_id);
if ($constCsCopyNoThirdParty == "1") :
$g_csc_id = "";
$g_cs_id = "";
$g_cscad_comp = "";
$statusMessage .= " " . getLngt("Der Drittzahler wurde ebenfalls entfernt!");
endif;
endif;
if ($companyId != "") :
// YYYYYYYYYYYYYYYYYYYYYYYYYY
endif;
// Only for output
$pageHeadline = getLngt("NEUER KUNDE");
$title = "