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 pt_cs_eid FROM prospect WHERE pt_cs_eid = '" . $f_cs_eid . "'")) : $statusMessage = getLngt("Die eindeutige Interessentennummer (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) : TA("B"); $currentTime = getDateTime("0"); // Insert prospect $f_cs_discount = str_replace (",", ".", $f_cs_discount); $f_cs_prov = str_replace (",", ".", $f_cs_prov); insertStmt("prospect", array("hq_id", $hq_id, "pt_cmp_comp", $f_cmp_comp, "pt_cmp_comp2", $f_cmp_comp2, "pt_cmp_authenticated", "1", "pt_cmp_visible", "1", "pt_cmp_hsno", $f_cmp_hsno, "pt_cs_eid", $f_cs_eid, "pt_cmp_cashmode", $f_cmp_cashmode, "pt_cs_discount", $f_cs_discount, "pt_cs_fixprice_discount", $f_cs_fixprice_discount, "pt_cs_invmode", $f_cs_invmode, "pt_cs_commission_no", $f_cs_commission_no, "pt_usr_name", $f_usr_name, "pt_usr_firstname", $f_usr_firstname, "pt_usr_email", $f_usr_email, "pt_usr_phone", $f_usr_phone, "pt_usr_phone2", $f_usr_phone2, "pt_usr_fax", $f_usr_fax, "pt_cmp_match", $f_cmp_match, "pt_cmp_match2", $f_cmp_match2, "pt_cmp_remark", $f_cmp_remark, "pt_cmp_remark2", $f_cmp_remark2)); $pt_id_new = getLastInsertId(); // 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("prospect", "pt_id", $pt_id_new, array("ad_id", $ad_id_new)); // Write logdata into log database writeToLogDB("67",$hq_id,"",$usr_id,"","","","STATUS_NEW=" . $logString,"",$pt_id_new); TA("C"); TA("E"); // Reset fields of form-parameters // clearParameters($httpVisualVars); // <= Moved to the end of the php-part of this script... $dbOperationCompleted = "1"; 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 prospect if ($f_act == "modifyCustomer" && $companyId != "") : if ($f_cmp_comp != "" && $f_usr_phone != "" && $f_ad_street != "" && $f_ad_zipcode != "" && $f_ad_city != "" && $f_cmp_hsno != "") : // $f_cs_eid != "" && $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))) : if ($db->getOne("SELECT pt_cs_eid FROM prospect WHERE pt_cs_eid = '" . $f_cs_eid . "' AND " . " NOT (pt_id = '" . $companyId . "')")) : $statusMessage = getLngt("Die eindeutige Interessentennummer (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"); // Update prospect $f_cs_discount = str_replace (",", ".", $f_cs_discount); $f_cs_prov = str_replace (",", ".", $f_cs_prov); $defaultFields = array("pt_cmp_comp", $f_cmp_comp, "pt_cmp_comp2", $f_cmp_comp2, "pt_cs_eid", $f_cs_eid, "pt_cmp_cashmode", $f_cmp_cashmode, "pt_cmp_hsno", $f_cmp_hsno, "pt_cs_discount", $f_cs_discount, "pt_cs_fixprice_discount", $f_cs_fixprice_discount, "pt_cs_invmode", $f_cs_invmode, "pt_cs_commission_no", $f_cs_commission_no, "pt_usr_name", $f_usr_name, "pt_usr_firstname", $f_usr_firstname, "pt_usr_email", $f_usr_email, "pt_usr_phone", $f_usr_phone, "pt_usr_phone2", $f_usr_phone2, "pt_usr_fax", $f_usr_fax, "pt_cmp_match", $f_cmp_match, "pt_cmp_match2", $f_cmp_match2, "pt_cmp_remark", $f_cmp_remark, "pt_cmp_remark2", $f_cmp_remark2); updateStmt("prospect","pt_id",$companyId,$defaultFields); // 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("prospect", "pt_id", $companyId, array("ad_id", $ad_id_new)); // Write logdata into log database writeToLogDB("68",$hq_id,"",$usr_id,"","","","STATUS_MODIFIED=" . $logString,"",$companyId); TA("C"); TA("E"); $dbOperationCompleted = "1"; 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; 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 prospect if ($f_act == "removeCustomer" && $companyId != "") : if (!existsEntry("prospect",array("pt_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("71",$hq_id,"",$usr_id,"","",$v_cs_id,"STATUS_DELETED"); // TA("C"); // TA("E"); // else : // $statusMessage = getLngt("Datenfehler! Merken Sie sich bitte den Datensatz und kontaktieren uns!!!"); // endif; endif; endif; // Set status of authentication of the prospect if ($f_act == "setAuthentication") : // Check for prospect if ($companyId != "") : if (existsEntry("prospect",array("pt_id",$companyId))) : // Update authentication-status updateStmt("prospect","pt_id",$companyId,array("pt_cmp_authenticated",$f_cmp_authenticated)); // Write logdata into log database writeToLogDB("69",$hq_id,"",$usr_id,"","","","STATUS_AUTHENTICATION=".$f_cmp_authenticated,"",$companyId); else : $statusMessage = getLngt("Der spezifizierte Interessent ist nicht im Datenbestand erhalten!"); endif; else : $statusMessage = getLngt("Sie haben keinen Interessenten spezifiziert!"); endif; endif; // Set status of visibility of the customer if ($f_act == "setVisibility") : // Check for company if ($companyId != "") : if (existsEntry("prospect",array("pt_id",$companyId))) : // Update authentication-status updateStmt("prospect","pt_id",$companyId,array("pt_cmp_visible",$f_cmp_visible)); // Write logdata into log database writeToLogDB("70",$hq_id,"",$usr_id,"","","","STATUS_VISIBILITY=".$f_cmp_visible,"",$companyId); else : $statusMessage = getLngt("Der spezifizierte Interessent ist nicht im Datenbestand erhalten!"); endif; else : $statusMessage = getLngt("Sie haben keinen Interessenten spezifiziert!"); endif; endif; // Set status of cash mode of the customer if ($f_act == "setCashmode") : // Check for company if ($companyId != "") : if (existsEntry("prospect",array("pt_id",$companyId))) : // Update authentication-status updateStmt("prospect","pt_id",$companyId,array("pt_cmp_cashmode",$f_cmp_cashmode)); // Write logdata into log database writeToLogDB("72",$hq_id,"",$usr_id,"","","","STATUS_CASHMODE=".$f_cmp_cashmode,"",$companyId); else : $statusMessage = getLngt("Der spezifizierte Interessent ist nicht im Datenbestand erhalten!"); endif; else : $statusMessage = getLngt("Sie haben keinen Interessenten spezifiziert!"); endif; endif; // ******************************************************************* // * Selection of the customer-data only for the current headquarter * // ******************************************************************* if ($companyId != "") : $sqlquery = "SELECT pt.pt_id, pt.hq_id, pt.pt_cmp_comp, pt.pt_cmp_comp2, pt.pt_cmp_hsno," . " pt.pt_cmp_remark, pt.pt_cmp_remark2, pt.pt_cmp_match," . " pt.pt_cmp_match2, pt.pt_cmp_cashmode, pt.pt_cs_discount, pt.pt_cs_eid," . " pt.pt_cs_invmode, pt.pt_cmp_authenticated, pt.pt_cmp_visible, pt.tx_id, pt.br_id," . " pt.pt_usr_name, pt.pt_usr_firstname, pt.pt_usr_email, pt.pt_usr_phone," . " pt.pt_usr_phone2, pt.pt_usr_fax, ad.ad_id, ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country" . " FROM prospect AS pt, address AS ad" . " WHERE pt.pt_id = $companyId AND" . getSQLMandatorPhrase($emp_id, "pt.hq_id = '" . $hq_id . "' AND") . " pt.ad_id = ad.ad_id"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $f_cmp_comp = $row["pt_cmp_comp"]; $f_cmp_comp2 = $row["pt_cmp_comp2"]; $f_cmp_hsno = $row["pt_cmp_hsno"]; $f_cmp_iln = $row["pt_cmp_iln"]; $f_cmp_tax_idno = $row["pt_cmp_tax_idno"]; $f_cmp_bank = $row["pt_cmp_bank"]; $f_cmp_bankno = $row["pt_cmp_bankno"]; $f_cmp_bankacc = $row["pt_cmp_bankacc"]; $f_cmp_bankmode = $row["pt_cmp_bankmode"]; $f_cmp_postage = $row["pt_cmp_postage"]; $f_cmp_inv2hq = $row["pt_cmp_inv2hq"]; $f_cmp_match = $row["pt_cmp_match"]; $f_cmp_match2 = $row["pt_cmp_match2"]; $f_cmp_remark = $row["pt_cmp_remark"]; $f_cmp_remark2 = $row["pt_cmp_remark2"]; $f_cmp_authenticated = $row["pt_cmp_authenticated"]; $f_cmp_authenticated2 = 0; if ($f_cmp_authenticated != "1") : $f_cmp_authenticated = 0; $f_cmp_authenticated2 = 1; endif; $f_cmp_visible = $row["pt_cmp_visible"]; $f_cmp_visible2 = 0; if ($f_cmp_visible != "1") : $f_cmp_visible = 0; $f_cmp_visible2 = 1; endif; $f_cmp_cashmode = $row["pt_cmp_cashmode"]; $f_cmp_cashmode2 = 0; if ($f_cmp_cashmode != "1") : $f_cmp_cashmode = 0; $f_cmp_cashmode2 = 1; endif; $f_pt_id = $row["pt_id"]; $f_cs_eid = $row["pt_cs_eid"]; $f_cs_hq_id = $row["hq_id"]; $f_cs_discount = $row["pt_cs_discount"]; $f_cs_invmode = $row["pt_cs_invmode"]; $f_cs_commission_no = $row["pt_cs_commission_no"]; $f_cs_cr_fav_only = $row["pt_cs_cr_fav_only"]; $f_cs_jobbatch = $row["pt_cs_jobbatch"]; $f_cs_invtext_mode = $row["pt_cs_invtext_mode"]; $f_cs_fixprice_discount = $row["pt_cs_fixprice_discount"]; $f_cs_prov = $row["pt_cs_prov"]; $f_usr_name = $row["pt_usr_name"]; $f_usr_firstname = $row["pt_usr_firstname"]; $f_usr_email = $row["pt_usr_email"]; $f_usr_phone = $row["pt_usr_phone"]; $f_usr_phone2 = $row["pt_usr_phone2"]; $f_usr_fax = $row["pt_usr_fax"]; $f_ad_id = $row["ad_id"]; $f_ad_street = $row["ad_street"]; $f_ad_zipcode = $row["ad_zipcode"]; $f_ad_city = $row["ad_city"]; $f_ad_country = $row["ad_country"]; $g_csc_id = $row["csc_id_payer"]; $g_tx_id = $row["tx_id"]; $g_br_id = $row["br_id"]; $g2_cs_id = $row["cs_id_parent"]; endwhile; $result->free(); endif; // Get the data of the tax if exists if ($g_tx_id != "") : $g_tx_sign = getFieldValueFromId("tax", "tx_id", "$g_tx_id", "tx_sign"); $g_tx_value = getFieldValueFromId("tax", "tx_id", "$g_tx_id", "tx_value"); endif; // Get the data of the branch if exists if ($g_br_id != "") : $g_br_key = getFieldValueFromId("branch", "br_id", "$g_br_id", "br_key"); $g_br_name = getFieldValueFromId("branch", "br_id", "$g_br_id", "br_name"); endif; // Get max-value of the EID of the current courier 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("prospect", "pt_cs_eid", "pt_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; // Check if a copy of the current prospect is requested. // If it is then reset some values if ($copyPt == "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!"); endif; // Only for output $title = getLngt("NEUER INTERESSENT"); $buttonCourier = ""; $buttonAuthentication = ""; $buttonVisibility = ""; $buttonCashmode = ""; $buttonGroup = ""; $displayTextAuthentication = ""; $displayTextVisibility = ""; $confirmTextAuthentication = ""; $confirmTextVisibility = ""; $confirmTextCashmode = ""; $serviceLink1 = ""; $serviceLink2 = ""; $serviceLink3 = ""; $serviceLink4 = ""; $buttonFilter = ""; $buttonService = ""; $buttonSetToCs = ""; $buttonCopy = ""; if ($companyId != "") : $title = getLngt("INTERESSENT:") . " " . substr($f_cmp_comp . " " . $f_cmp_comp2, 0, 100); // Show mandator if (authCheckEmployeeRights($emp_id, "10")) : // Name of the headquarter $hq_name = getFieldValueFromId("headquarters", "hq_id", $f_cs_hq_id, "hq_name"); $title .= " "; $title .= "[" . $hq_name . "]"; endif; // $buttonCourier = defineButtonType08(getLngt("Transporteure"), "action_cr", "openCustomerCouriers();", "90", "left", "3"); // $buttonFilter = defineButtonType08(getLngt("Filter"), "action_crf", "openCustomerFilters();", "90", "left", "3"); // $buttonService = defineButtonType08(getLngt("Services"), "action_srv", "openCustomerServices();", "90", "left", "3"); $buttonCopy = defineButtonType08(getLngt("Kopie"), "action_copy", "copyProspect();", "90", "left", "3"); $buttonSetToCs = defineButtonType08(getLngt("Kunde"), "action_move", "setProspectToCustomer('" . ec($companyId) . "');", "90", "left", "3"); // $buttonGroup = defineButtonType08(getLngt("Gruppen"), "action_grp", "openGroups('" . ec($companyId) . "');", "90", "left", "3"); $buttonAuthentication = defineButtonType08(getLngt("Sperren"), "action_lock", "authenticationFinishPage();", "90", "left", "3"); $confirmTextAuthentication = getLngt("Soll der Interessent wirklich gesperrt werden?"); if ($f_cmp_authenticated != "1") : $buttonAuthentication = defineButtonType08(getLngt("Freischalten"), "action_lock", "authenticationFinishPage();", "90", "left", "3"); $displayTextAuthentication = getLngt("(gesperrt)"); $confirmTextAuthentication = getLngt("Soll der Interessent wirklich freigeschaltet werden?"); endif; $buttonVisibility = defineButtonType08(getLngt("Ausblenden"), "action_visible", "visibilityFinishPage();", "90", "left", "3"); $confirmTextVisibility = getLngt("Soll der Interessent wirklich ausgeblendet werden?"); if ($f_cmp_visible != "1") : $buttonVisibility = defineButtonType08(getLngt("Einblenden"), "action_visible", "visibilityFinishPage();", "90", "left", "3"); $displayTextVisibility = getLngt("(ausgeblendet)"); $confirmTextVisibility = getLngt("Soll der Interessent wirklich eingeblendet werden?"); endif; // $buttonCashmode = defineButtonType08(getLngt("Rechnung"), "action_cashmode", "cashModeFinishPage();", "90", "left", "3"); $confirmTextCashmode = getLngt("Soll der Interessent zukünftig wieder Rechnungen erhalten?"); if ($f_cmp_cashmode != "1") : // $buttonCashmode = defineButtonType08(getLngt("Nur bar"), "action_cashmode", "cashModeFinishPage();", "90", "left", "3"); $confirmTextCashmode = getLngt("Soll der Interessent zukünftig wirklich nur barzahlen?"); endif; $buttonCostcenter = ""; // IMPORTANT: Check if customer-admin-user-account exists, because in this case only the customer has to administrate the costcenters !!! if ($f_usr_account == "") : // $buttonCostcenter = defineButtonType08(getLngt("Kostenstellen"), "action_csc", "openCostcenterAdmin();", "90", "left", "3"); endif; /* if (authCheckEmployeeRights($emp_id, "2")) : $serviceLink1 = "Service: " . getLngt("Preise") . "/" . "" . getLngt("Rabatte") . "\n"; $serviceLink2 = "PLZ: " . getLngt("Preise") . "/" . "" . getLngt("Rabatte") . "\n"; $serviceLink3 = "PLZ-Bereiche: " . getLngt("Preise") . "/" . "" . getLngt("Rabatte") . "\n"; $serviceLink4 = "\n"; else : $serviceLink1 = getLngt("Service: Preise/Rabatte") . "\n"; $serviceLink2 = getLngt("PLZ: Preise/Rabatte") . "\n"; $serviceLink3 = getLngt("PLZ-Bereiche: Preise/Rabatte") . "\n"; $serviceLink4 = "\n"; endif; */ endif; // Password-fields for entering a new customer (admin-user) $setPasswordForNewUserOutput = "