same values for ALL mandators $currentHqId = $hq_id; if ($serviceMode >= "1") : $constHqId = getParameterValue("0", "MANDATOR_SERVICE2_ENABLED", $hq_id); else : $constHqId = getParameterValue("0", "MANDATOR_SERVICE_ENABLED", $hq_id); endif; if ($constHqId == "" || $constHqId == "0") : $currentHqId = "0"; endif; // ***************************** // * Selection of all services * // ***************************** $sqlquery = "SELECT srv_id, srv_name" . " FROM service" . " WHERE hq_id = '" . $currentHqId . "' AND cs_id = '0' AND srv_mode = '" . $serviceMode . "'" . " ORDER BY srv_sort"; $result = $db->dbQ($sqlquery); $services = array(); $count = 0; while ($row = $result->fetch_assoc()): $count++; $services["id"][$count] = $row["srv_id"]; $services["name"][$count] = $row["srv_name"]; endwhile; $result->free(); // ********************************* // * Selection of all servicetypes * // ********************************* $sqlquery = "SELECT srvt_id, srvt_name" . " FROM servicetype" . " WHERE hq_id = '" . $currentHqId . "' AND cs_id = '0' AND srvt_mode = '" . $serviceMode . "'"; $result = $db->dbQ($sqlquery); $serviceTypes = array(); $count = 0; while ($row = $result->fetch_assoc()): $count++; $serviceTypes["id"][$count] = $row["srvt_id"]; $serviceTypes["name"][$count] = $row["srvt_name"]; endwhile; $result->free(); // Number of entries $lenServices = count($services["id"]); $lenServiceTypes = count($serviceTypes["id"]); if ($customerId != "") : $customerHqId = getFieldValueFromId("customer", "cs_id", $customerId, "hq_id"); // Get current address of the current customer $csAdId = ""; $sqlquery = "SELECT ad.ad_id, ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country, cscad.cscad_hsno" . " FROM customer AS cs, costcenter AS csc, costcenteraddress AS cscad, address AS ad" . " WHERE cs.hq_id = '" . $customerHqId . "' AND" . " cs.cs_id = '" . $customerId . "' AND" . " cs.csc_id = csc.csc_id AND" . " csc.csc_id = cscad.csc_id AND" . " cscad.adt_id = '4' AND" . " cscad.ad_id = ad.ad_id"; $result = $db->dbQ($sqlquery); while ($row = $result->fetch_assoc()): $csAdId = $row["ad_id"]; $csAdStreet = $row["ad_street"]; $csAdHsno = $row["cscad_hsno"]; $csAdZipcode = $row["ad_zipcode"]; $csAdCity = $row["ad_city"]; $csAdCountry = $row["ad_country"]; endwhile; $result->free(); if ($csAdId == "") : // Get address of out of the customer master data $address = getAddress($customerId, "customer"); $csAdId = $address["id"]; $csAdStreet = $address["street"]; $csAdHsno = $address["hsno"]; $csAdZipcode = $address["zipcode"]; $csAdCity = $address["city"]; $csAdCountry = $address["country"]; endif; // Set services of the current customer if ($f_act == "saveCustomerServices") : TA("B"); // [1.] Set customer services if (!is_array($f_cs_service)) : $f_cs_service = array(); endif; deleteStmt("customerservice","cs_id = '" . $customerId . "'"); $lenCsServiceStore = count($f_cs_service); for ($i = 0; $i < $lenCsServiceStore; $i++) : insertStmt("customerservice", array("cs_id", $customerId, "srv_id", $f_cs_service[$i], "cssrv_sort", $i)); endfor; // [2.] Set customer servicetypes if (!is_array($f_cs_servicetype)) : $f_cs_servicetype = array(); endif; deleteStmt("customerservicetype","cs_id = '" . $customerId . "'"); $lenCsServiceTypeStore = count($f_cs_servicetype); for ($i = 0; $i < $lenCsServiceTypeStore; $i++) : insertStmt("customerservicetype", array("cs_id", $customerId, "srvt_id", $f_cs_servicetype[$i], "cssrvt_sort", $i)); endfor; TA("C"); TA("E"); endif; // Compute new radiuses of the current customer if ($f_act == "newRadiuses" && $csAdId != "") : // if (true || existsEntry("serviceradius",array("hq_id",$customerHqId,"cs_id",$customerId))) : // Execution-Time for script set_time_limit(0); TA("B"); // First remove existing entries regarding the customer in $customerId deleteStmt("serviceradius","hq_id = '" . $customerHqId . "' AND cs_id = '" . $customerId . "'"); $long = ""; $lat = ""; // $coords[0][0] : 100 = gefunden // $coords[0][1] : Länge // $coords[0][2] : Breite $coords = XSfindAddress("D", $csAdZipcode, $csAdCity, $csAdStreet, $csAdHsno); if ($coords[0][0] == 100) : // Found $long = $coords[0][1]; $lat = $coords[0][2]; $parRadiusIntervalsArray = array(); $parRadiusIntervals = getParameterValue("0", "CUSTOMER_SERVICE_RADIUS_INTERVALS_" . $customerId, $customerHqId); if ($parRadiusIntervals == "") : $parRadiusIntervals = "1=10|2=20,10|3=30,20"; endif; $parRadiusIntervalsArray = getKeyValueArrayFromString($parRadiusIntervals); $tmpKeys = array_keys($parRadiusIntervalsArray); sort($tmpKeys); $tmpKeysLen = count($tmpKeys); for ($k = 0; $k < $tmpKeysLen; $k++) : $tmpDistanceArray = spliti(",",$parRadiusIntervalsArray[$tmpKeys[$k]]); $distance = $tmpDistanceArray[0]; $distance2 = $tmpDistanceArray[1]; if ($distance != "" && is_numeric($distance)) : if ($distance2 == "0" || !is_numeric($distance2)) : $distance2 = ""; endif; $radiusAreaNo = $k + 1; // Get all areas $tmpArray = getDistanceData($distance, $long, $lat, $distance2); $tmpArrayLen = count($tmpArray); for ($j = 0; $j < $tmpArrayLen; $j++) : // Insert into db $tmpIncArray = array(); if (($j + 1) < $tmpArrayLen) : $tmpIncArray = $tmpArray[($j + 1)]; endif; $srvr_id_new = insertServiceRadius($tmpArray[$j], $customerHqId, $customerId, $radiusAreaNo, $tmpIncArray); endfor; endif; endfor; endif; TA("C"); TA("E"); // endif; endif; // Insert new radius mapping // Main definition of the zones of a special customer by data import! if ($f_act == "insertNewRadiusMapping") : $f_radius_zipcode_new = trim($f_radius_zipcode_new); $f_radius_district_new = trim($f_radius_district_new); if ($f_radius_zipcode_new != "" && $f_radius_district_new != "" && $f_radius_zone_new != "") : // Get srvp_id from serviceplz $tmpSrvpId = getFieldValueFromId("serviceplz", "srvp_plz", $f_radius_zipcode_new, "srvp_id"); if ($tmpSrvpId != "") : // Check for existence in "serviceradius" $sqlquery = "SELECT srvr.srvr_radiusarea_no FROM serviceradius AS srvr" . " WHERE srvr.hq_id = '" . $customerHqId . "' AND srvr.cs_id = '" . $customerId . "' AND srvr.srvr_zipcode = '" . $f_radius_zipcode_new . "'"; $result = $db->dbQ($sqlquery); $existingSrvrNo = ""; while ($row = $result->fetch_assoc()): $existingSrvrNo = $row["srvr_radiusarea_no"]; endwhile; $result->free(); // Multiple entries are ok, because one zipcode may have more districts // if ($existingSrvrNo == "") : insertStmt("serviceradius", array("hq_id", $customerHqId, "cs_id", $customerId, "srvr_zipcode", $f_radius_zipcode_new, "srvr_city_district", $f_radius_district_new, "srvr_radiusarea_no", $f_radius_zone_new)); $statusMessage = getLngt("Die PLZ " . $f_radius_zipcode_new . " (" . $f_radius_district_new . ") wurde dem Radiusbereich " . $f_radius_zone_new . " zugeordnet!"); if ($existingSrvrNo != "") : $statusMessage = getLngt("INFO: Für die PLZ " . $f_radius_zipcode_new . " existiert schon eine Zuordnung im Radiusbereich " . $existingSrvrNo . "."); endif; // else : // $statusMessage = getLngt("Für die PLZ " . $f_radius_zipcode_new . " existiert schon eine Zuordnung im Radiusbereich " . $existingSrvrNo . ". Diese müsste ggfs. entfernt werden!"); // endif; else : $statusMessage = getLngt("Die PLZ " . $f_radius_zipcode_new . " wird im Basisdatenbestand nicht geführt. Eine Zuordnung erfolgte nicht!"); endif; else : $statusMessage = getLngt("Bitte geben Sie eine PLZ und einen Bezirk ein und wählen Sie eine Zone aus!"); endif; endif; // Remove existing mappings between zipcode an radius zone if ($f_act == "removeRadiusMappings") : if (is_array($f_srvr_remove)) : $f_srvr_remove_len = count($f_srvr_remove); for ($i = 0; $i < $f_srvr_remove_len; $i++) : if ($f_srvr_remove[$i] != "") : deleteStmt("serviceradius","srvr_id = '" . $f_srvr_remove[$i] . "'"); endif; endfor; endif; endif; // Insert new (service) zone if ($f_act == "insertNewServiceZone") : $f_zone_name_new = trim($f_zone_name_new); if ($f_zone_name_new != "" && $f_zone_name_new != "") : TA("B"); // Get max value of zone number (srvz_no) for customer in servicezone $tmpSrvzNoMaxValue = getMaxOfField("servicezone", "srvz_no", "hq_id = '" . $customerHqId . "' AND cs_id = '" . $customerId . "'"); if ($tmpSrvzNoMaxValue != "" && is_numeric($tmpSrvzNoMaxValue)) : $tmpSrvzNoMaxValue++; else : $tmpSrvzNoMaxValue = 0; endif; insertStmt("servicezone", array("hq_id", $customerHqId, "cs_id", $customerId, "srvz_no", $tmpSrvzNoMaxValue, "srvz_name", $f_zone_name_new)); TA("C"); TA("E"); else : $statusMessage = getLngt("Bitte geben Sie eine Zonenbezeichnung ein!"); endif; endif; // Remove existing (service) zone if ($f_act == "removeServiceZone") : if (is_array($f_srvz_remove)) : TA("B"); $logArray = array(); $f_srvz_remove_len = count($f_srvz_remove); for ($i = 0; $i < $f_srvz_remove_len; $i++) : $tmpSrvzId = $f_srvz_remove[$i]; if ($tmpSrvzId != "" && $tmpSrvzId != "") : $tmpSrvzNo = getFieldValueFromId("servicezone", "srvz_id", $tmpSrvzId, "srvz_no"); $tmpSrvzName = getFieldValueFromId("servicezone", "srvz_id", $tmpSrvzId, "srvz_name"); $logArray[] = "[" . $tmpSrvzId . "|" . $tmpSrvzNo . "|" . $tmpSrvzName . "]"; deleteStmt("servicezonemapping","srvz_id = '" . $tmpSrvzId . "'"); deleteStmt("servicezone","srvz_id = '" . $tmpSrvzId . "'"); endif; endfor; if (count($logArray) > 0) : // Write logdata into log database writeToLogDB("135",$customerHqId,"",$usr_id,"","",$customerId,"[ID,NO,NAME]=" . implode(",",$logArray)); endif; TA("C"); TA("E"); endif; endif; // Insert new zone mapping if ($f_act == "insertNewZoneMapping") : $f_zone_zipcode_new = trim($f_zone_zipcode_new); if ($f_zone_zipcode_new != "" && $f_zone_zone_new != "") : // Get srvp_id from serviceplz $tmpSrvpId = getFieldValueFromId("serviceplz", "srvp_plz", $f_zone_zipcode_new, "srvp_id"); if ($tmpSrvpId != "") : // Check for existence in "servicezonemapping" $existingSrvzNo = getServiceZoneByCustomerAndZipcode($customerId, $f_zone_zipcode_new); if ($existingSrvzNo == "") : insertStmt("servicezonemapping", array("srvz_id", $f_zone_zone_new, "srvp_id", $tmpSrvpId)); $statusMessage = getLngt("Die PLZ " . $f_zone_zipcode_new . " wurde der Zone " . getFieldValueFromId("servicezone", "srvz_id", $f_zone_zone_new, "srvz_no") . " zugeordnet!"); else : $statusMessage = getLngt("Für die PLZ " . $f_zone_zipcode_new . " existiert schon eine Zuordnung in der Zone " . $existingSrvzNo . ". Diese müsste ggfs. entfernt werden!"); endif; else : $statusMessage = getLngt("Die PLZ " . $f_zone_zipcode_new . " wird im Basisdatenbestand nicht geführt. Eine Zuordnung erfolgte nicht!"); endif; else : $statusMessage = getLngt("Bitte geben Sie eine PLZ ein und wählen Sie eine Zone aus, der die PLZ zogeordnet wird!"); endif; endif; // Remove existing mappings between zipcode an zone if ($f_act == "removeZoneMappings") : if (is_array($f_srvz_mapping_remove)) : $f_srvz_mapping_remove_len = count($f_srvz_mapping_remove); for ($i = 0; $i < $f_srvz_mapping_remove_len; $i++) : $tmpItem = $f_srvz_mapping_remove[$i]; $tmpArray = spliti(",", $tmpItem); $tmpSrvpId = $tmpArray[0]; $tmpSrvzId = $tmpArray[1]; if ($tmpSrvpId != "" && $tmpSrvzId != "") : deleteStmt("servicezonemapping","srvp_id = '" . $tmpSrvpId . "' AND srvz_id = '" . $tmpSrvzId . "'"); endif; endfor; endif; endif; // Reset day times to defaults if ($f_act == "day_time_defaults") : TA("B"); metatypeSetDefaultValues("day_time", "cs", $customerId); TA("C"); TA("E"); endif; // Insert new day time if ($f_act == "day_time_new" && $f_day_time_new != "") : TA("B"); // Get max value for customer in metatype for mt_type = "day_time", increment this value and insert the new one $tmpSortValue = getMaxOfField("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($tmpSortValue != "" && is_numeric($tmpSortValue)) : $tmpSortValue++; else : $tmpSortValue = 0; endif; $tmpInterval = pad($f_day_time_hour_from_new, 2) . ":" . pad($f_day_time_minute_from_new, 2) . " - " . pad($f_day_time_hour_to_new, 2) . ":" . pad($f_day_time_minute_to_new, 2); insertStmt("metatype", array("mt_type", "day_time", "mt_objtype", "cs", "mt_objid", $customerId, "mt_sort", $tmpSortValue, "mt_value", $f_day_time_new, "mt_mapped_value", $tmpInterval)); TA("C"); TA("E"); endif; // Remove day time if ($f_act == "day_time_remove") : TA("B"); // Get max value for customer in metatype for mt_type = "day_time" and remove it $tmpSortValue = getMaxOfField("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($tmpSortValue != "" && is_numeric($tmpSortValue)) : deleteStmt("metatype", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "' AND mt_sort = '" . $tmpSortValue . "'"); endif; TA("C"); TA("E"); endif; // Reset delivery times to defaults if ($f_act == "delivery_time_defaults") : TA("B"); metatypeSetDefaultValues("delivery_time", "cs", $customerId); TA("C"); TA("E"); endif; // Insert new delivery time if ($f_act == "delivery_time_new" && $f_delivery_time_new != "") : TA("B"); // Get max value for customer in metatype for mt_type = "delivery_time", increment this value and insert the new one $tmpSortValue = getMaxOfField("metatype", "mt_sort", "mt_type = 'delivery_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($tmpSortValue != "" && is_numeric($tmpSortValue)) : $tmpSortValue++; else : $tmpSortValue = 0; endif; // $tmpInterval = pad($f_delivery_time_hour_from_new, 2) . ":" . pad($f_delivery_time_minute_from_new, 2) . " - " . pad($f_delivery_time_hour_to_new, 2) . ":" . pad($f_delivery_time_minute_to_new, 2); $tmpInterval = pad($f_delivery_time_hour_to_new, 2) . ":" . pad($f_delivery_time_minute_to_new, 2); // Presently only "to time" only !!!! insertStmt("metatype", array("mt_type", "delivery_time", "mt_objtype", "cs", "mt_objid", $customerId, "mt_sort", $tmpSortValue, "mt_value", $f_delivery_time_new, "mt_mapped_value", $tmpInterval)); TA("C"); TA("E"); endif; // Remove delivery time if ($f_act == "delivery_time_remove") : TA("B"); // Get max value for customer in metatype for mt_type = "delivery_time" and remove it $tmpSortValue = getMaxOfField("metatype", "mt_sort", "mt_type = 'delivery_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($tmpSortValue != "" && is_numeric($tmpSortValue)) : deleteStmt("metatype", "mt_type = 'delivery_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "' AND mt_sort = '" . $tmpSortValue . "'"); endif; TA("C"); TA("E"); endif; // Reset discount mode to defaults if ($f_act == "discount_mode_defaults") : TA("B"); metatypeSetDefaultValues("discount_mode", "cs", $customerId); TA("C"); TA("E"); endif; // Insert new discount mode if ($f_act == "discount_mode_new" && $f_discount_mode_new != "" && $f_discount_mode_type_new != "") : TA("B"); // Get max value for customer in metatype for mt_type = "discount_mode", increment this value and insert the new one $tmpSortValue = getMaxOfField("metatype", "mt_sort", "mt_type = 'discount_mode' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($tmpSortValue != "" && is_numeric($tmpSortValue)) : $tmpSortValue++; else : $tmpSortValue = 0; endif; insertStmt("metatype", array("mt_type", "discount_mode", "mt_objtype", "cs", "mt_objid", $customerId, "mt_sort", $tmpSortValue, "mt_value", $f_discount_mode_new, "mt_mapped_value", $f_discount_mode_type_new)); TA("C"); TA("E"); endif; // Remove discount mode if ($f_act == "discount_mode_remove") : TA("B"); // Get max value for customer in metatype for mt_type = "discount_mode" and remove it $tmpSortValue = getMaxOfField("metatype", "mt_sort", "mt_type = 'discount_mode' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($tmpSortValue != "" && is_numeric($tmpSortValue)) : deleteStmt("metatype", "mt_type = 'discount_mode' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "' AND mt_sort = '" . $tmpSortValue . "'"); endif; TA("C"); TA("E"); endif; // Set SMS time to default if ($f_act == "sms_time_default") : TA("B"); metatypeSetDefaultValues("sms_time", "cs", $customerId); TA("C"); TA("E"); endif; // Insert new SMS time if ($f_act == "sms_time_new" && $f_sms_time_hour_from_new != "" && $f_sms_time_minute_from_new != "") : TA("B"); $tmpClockTime = pad($f_sms_time_hour_from_new, 2) . ":" . pad($f_sms_time_minute_from_new, 2); deleteStmt("metatype", "mt_type = 'sms_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); insertStmt("metatype", array("mt_type", "sms_time", "mt_objtype", "cs", "mt_objid", $customerId, "mt_sort", "0", "mt_mapped_value", $tmpClockTime)); TA("C"); TA("E"); endif; // Set time for cartage protocol to default if ($f_act == "cartage_time_default") : TA("B"); metatypeSetDefaultValues("cartage_time", "cs", $customerId); TA("C"); TA("E"); endif; // Insert new SMS time if ($f_act == "cartage_time_new" && $f_cartage_time_hour_from_new != "" && $f_cartage_time_minute_from_new != "") : TA("B"); $tmpClockTime = pad($f_cartage_time_hour_from_new, 2) . ":" . pad($f_cartage_time_minute_from_new, 2); deleteStmt("metatype", "mt_type = 'cartage_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); insertStmt("metatype", array("mt_type", "cartage_time", "mt_objtype", "cs", "mt_objid", $customerId, "mt_sort", "0", "mt_mapped_value", $tmpClockTime)); TA("C"); TA("E"); endif; // Get customer services $sqlquery = "SELECT srv_id FROM customerservice WHERE cs_id = '" . $customerId . "' ORDER BY cssrv_sort"; $result = $db->dbQ($sqlquery); $csServices = array(); while ($row = $result->fetch_assoc()): $csServices[$row["srv_id"]] = "1"; endwhile; $result->free(); // Get customer servicetypes $sqlquery = "SELECT srvt_id FROM customerservicetype WHERE cs_id = '" . $customerId . "' ORDER BY cssrvt_sort"; $result = $db->dbQ($sqlquery); $csServiceTypes = array(); while ($row = $result->fetch_assoc()): $csServiceTypes[$row["srvt_id"]] = "1"; endwhile; $result->free(); // ********************************** // * Selection of all serviceradius * // ********************************** $sqlquery = "SELECT srvr_zipcode, srvr_city_district, srvr_radiusarea_no, srvr_id" . " FROM serviceradius" . " WHERE hq_id = '" . $customerHqId . "' AND cs_id = '" . $customerId . "'" . " ORDER BY srvr_zipcode, srvr_city_district"; $result = $db->dbQ($sqlquery); $serviceRadiuses = array(); $count = 0; while ($row = $result->fetch_assoc()): $count++; $serviceRadiuses[] = array($row["srvr_zipcode"], $row["srvr_city_district"], $row["srvr_radiusarea_no"], $row["srvr_id"]); endwhile; $result->free(); // Number of entries $lenServiceRadiuses = count($serviceRadiuses); // ********************************* // * Selection of all servicezones * // ********************************* $sqlquery = "SELECT srvz.srvz_id, srvz.srvz_no, srvz.srvz_name, srvz.srvz_price, srvz.srvz_price_1, srvz.srvz_price_2, srvz.srvz_price_3" . " FROM servicezone AS srvz" . " WHERE srvz.hq_id = '" . $customerHqId . "' AND srvz.cs_id = '" . $customerId . "'" . " ORDER BY srvz_no"; $result = $db->dbQ($sqlquery); $serviceZones = array(); $count = 0; while ($row = $result->fetch_assoc()): $count++; $serviceZones[] = array($row["srvz_id"], $row["srvz_no"], $row["srvz_name"], $row["srvz_price"], $row["srvz_price_1"], $row["srvz_price_2"], $row["srvz_price_3"]); endwhile; $result->free(); // Number of entries $lenServiceZones = count($serviceZones); // **************************************** // * Selection of all servicezonemappings * // **************************************** $sqlquery = "SELECT srvp.srvp_plz, srvz.srvz_no, srvz.srvz_id, srvp.srvp_id, srvzm.srvzm_mt_1, srvzm.srvzm_mt_2, srvzm.srvzm_mt_3" . " FROM servicezone AS srvz, servicezonemapping AS srvzm, serviceplz AS srvp" . " WHERE srvz.hq_id = '" . $customerHqId . "' AND srvz.cs_id = '" . $customerId . "' AND" . " srvz.srvz_id = srvzm.srvz_id AND srvzm.srvp_id = srvp.srvp_id" . " ORDER BY srvp_plz, srvz_no"; $result = $db->dbQ($sqlquery); $serviceZoneMapping = array(); $count = 0; while ($row = $result->fetch_assoc()): $count++; $serviceZoneMapping[] = array($row["srvp_plz"], $row["srvz_no"], $row["srvz_id"], $row["srvp_id"], $row["srvzm_mt_1"], $row["srvzm_mt_2"], $row["srvzm_mt_3"]); endwhile; $result->free(); // Number of entries $lenServiceZoneMapping = count($serviceZoneMapping); // ********************************** // * Get day times for the customer * // ********************************** // if (existsEntry("metatype",array("mt_type", "day_time", "mt_objtype", "cs", "mt_objid", $customerId))) : $dayTimes = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); $dayTimeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); $dayTimeMappedValues = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); // else : // $dayTimes = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); // $dayTimeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'day_time' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); // $dayTimeMappedValues = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = 'day_time' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); // endif; $dayTimesLen = count($dayTimes); // *************************************** // * Get discount modes for the customer * // *************************************** // if (existsEntry("metatype",array("mt_type", "discount_mode", "mt_objtype", "cs", "mt_objid", $customerId))) : $discountMode = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'discount_mode' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); $discountModeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'discount_mode' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); $discountModeMappedValues = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = 'discount_mode' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); // else : // $discountMode = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'discount_mode' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); // $discountModeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'discount_mode' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); // $discountModeMappedValues = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = 'discount_mode' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); // endif; $discountModeLen = count($discountMode); // *************************************** // * Get delivery times for the customer * // *************************************** if (!existsEntry("metatype",array("mt_type", "delivery_time", "mt_objtype", "cs", "mt_objid", $customerId))) : metatypeSetDefaultValues("delivery_time", "cs", $customerId); // Set default if no entry does exist endif; $deliveryTimes = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'delivery_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); $deliveryTimeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'delivery_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); $deliveryTimeMappedValues = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = 'delivery_time' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'", "", "mt_sort", ""); $deliveryTimesLen = count($deliveryTimes); endif; // ******************* // * Generate output * // ******************* // * Day times * $outputDayTimes = "
"; if (isset($dayTimesLen) && $dayTimesLen > 0) : for ($i = 0; $i < $dayTimesLen; $i++) : $outputDayTimes .= "\n"; endfor; endif; // if ($i == "") : $i = 0; endif; mcIsSet($i, "0"); $outputDayTimes .= "\n"; $outputDayTimes .= "\n"; $outputDayTimes .= "\n"; $outputDayTimes .= "\n"; $outputDayTimes .= "\n"; $outputDayTimes .= "
" . $dayTimes[$i] . "  " . $dayTimeNames[$i] . "  (" . $dayTimeMappedValues[$i] . ")
" . $i . "" . "" . " (" . getLngt("Uhrzeit") . " "; $outputDayTimes .= getLngt("von") . " " . "\n"; $outputDayTimes .= " " . "\n"; $outputDayTimes .= getLngt("bis") . " " . "\n"; $outputDayTimes .= " " . ")\n"; $outputDayTimes .= "
"; // * Discount modes * $outputDiscountModes = "
"; $i = 0; if (isset($discountModeLen) && $discountModeLen > 0) : for ($i = 0; $i < $discountModeLen; $i++) : $outputDiscountModes .= "\n"; endfor; endif; if ($i == "") : $i = 0; endif; $outputDiscountModes .= "\n"; $outputDiscountModes .= "\n"; $outputDiscountModes .= "\n"; $outputDiscountModes .= "\n"; $outputDiscountModes .= "\n"; $outputDiscountModes .= "
" . $discountMode[$i] . "  " . $discountModeNames[$i] . "  (" . getFieldValueFromClause("metatype","mt_value","mt_type = 'discount_mode' AND mt_sort = '" . $discountMode[$i] . "' AND mt_objtype = '' AND mt_objid = '0'") . ")
" . $i . "" . "" . " (" . getLngt("Rabatt-Typ") . " "; $outputDiscountModes .= ")\n"; $outputDiscountModes .= "
"; // * Delivery times * $outputDeliveryTimes = "
"; if (isset($deliveryTimesLen) && $deliveryTimesLen > 0) : for ($i = 0; $i < $deliveryTimesLen; $i++) : $outputDeliveryTimes .= "\n"; endfor; endif; if ($i == "") : $i = 0; endif; // Check for number of entries explicitly, because the delivery times corresponds with database fields in "servicezone" (price fields) and "servicezonemapping" (flags activated zipcodes for each delivery time (like "express", etc.)) if ($deliveryTimesLen <= 3) : $outputDeliveryTimes .= "\n"; $outputDeliveryTimes .= "\n"; $outputDeliveryTimes .= "\n"; $outputDeliveryTimes .= "\n"; $outputDeliveryTimes .= "\n"; endif; $outputDeliveryTimes .= "
" . $deliveryTimes[$i] . "  " . $deliveryTimeNames[$i] . "  " . ($deliveryTimeMappedValues[$i] != "" ? "(" . $deliveryTimeMappedValues[$i] . ")" : "") . "
" . $i . "" . "" . " (" . getLngt("Max. Bestelluhrzeit") . " "; // $outputDeliveryTimes .= getLngt("von") . " " . "\n"; // $outputDeliveryTimes .= " " . "\n"; $outputDeliveryTimes .= getLngt("bis") . " " . "\n"; $outputDeliveryTimes .= " " . ")\n"; $outputDeliveryTimes .= "
"; // * SMS times * $mtSmsTime = getFieldValueFromClause("metatype","mt_mapped_value","mt_type = 'sms_time' AND mt_sort = '0' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($mtSmsTime == "") : // Get default value $mtSmsTime = getFieldValueFromClause("metatype","mt_mapped_value","mt_type = 'sms_time' AND mt_sort = '0' AND mt_objtype = '' AND mt_objid = '0'"); endif; $smsHourSet = ""; $smsMinuteSet = ""; if ($mtSmsTime != "") : $smsHourSet = substr($mtSmsTime,0,2); $smsMinuteSet = substr($mtSmsTime,3,2); endif; $outputSmsTimes = "
"; $outputSmsTimes .= "\n"; $outputSmsTimes .= "\n"; $outputSmsTimes .= "\n"; $outputSmsTimes .= "
(" . getLngt("Uhrzeit") . " "; $outputSmsTimes .= "\n"; $outputSmsTimes .= " " . "\n"; $outputSmsTimes .= "
"; // * Cartage protocol times * $mtCartageTime = getFieldValueFromClause("metatype","mt_mapped_value","mt_type = 'cartage_time' AND mt_sort = '0' AND mt_objtype = 'cs' AND mt_objid = '" . $customerId . "'"); if ($mtCartageTime == "") : // Get default value $mtCartageTime = getFieldValueFromClause("metatype","mt_mapped_value","mt_type = 'cartage_time' AND mt_sort = '0' AND mt_objtype = '' AND mt_objid = '0'"); endif; $cartageHourSet = ""; $cartageMinuteSet = ""; if ($mtCartageTime != "") : $cartageHourSet = substr($mtCartageTime,0,2); $cartageMinuteSet = substr($mtCartageTime,3,2); endif; $outputCartageTimes = "
"; $outputCartageTimes .= "\n"; $outputCartageTimes .= "\n"; $outputCartageTimes .= "\n"; $outputCartageTimes .= "
(" . getLngt("Uhrzeit") . " "; $outputCartageTimes .= "\n"; $outputCartageTimes .= " " . "\n"; $outputCartageTimes .= "
"; $output = "
"; // * Services * $output .= "\n"; $output .= "\n"; $lineToggler = 0; for ($i = 1; $i <= $lenServices; $i++) : if ($lineToggler == 0) : $lineToggler = 1; else : $lineToggler = 0; endif; $cellColor = getListColor($i, $lineToggler); $isChecked = ""; mcArrIsSet($csServices, $services["id"][$i]); if ($csServices[$services["id"][$i]] == "1") : $isChecked = " checked "; endif; $output .= "\n"; $output .= "\n"; $output .= "\n"; $output .= ""; endfor; $output .= "
" . getLngt("Preistyp") . "
" . $services["name"][$i] . "
\n"; $output .= "
  \n"; $output .= "\n"; $output .= "\n"; $lineToggler = 0; for ($i = 1; $i <= $lenServiceTypes; $i++) : if ($lineToggler == 0) : $lineToggler = 1; else : $lineToggler = 0; endif; $cellColor = getListColor($i, $lineToggler); $isChecked = ""; mcArrIsSet($csServiceTypes, $serviceTypes["id"][$i]); if ($csServiceTypes[$serviceTypes["id"][$i]] == "1") : $isChecked = " checked "; endif; $output .= "\n"; $output .= "\n"; $output .= "\n"; $output .= ""; endfor; $output .= "
" . getLngt("Leistungstyp") . "
" . $serviceTypes["name"][$i] . "
\n"; // * Radiuses * if ($customerId != "") : // && $lenServiceRadiuses > 0 $output .= "
 \n"; $output .= "\n"; $output .= "\n"; $output .= "\n"; $output .= "\n"; $selectRadiuses = ""; $buttonRadiusNew = defineButtonType10(getLngt("Neu"), "action_radiusmapping_new", "finishPage('insertNewRadiusMapping');", "100", "left", "0"); $output .= "" . "" . "\n"; $lineToggler = 0; for ($i = 0; $i < $lenServiceRadiuses; $i++) : if ($lineToggler == 0) : $lineToggler = 1; else : $lineToggler = 0; endif; $cellColor = getListColor($i, $lineToggler); $tmpArray = $serviceRadiuses[$i]; $output .= "\n"; $output .= ""; $output .= ""; $output .= "\n"; $isChecked = ""; $output .= "\n"; $output .= "\n"; endfor; $output .= "
" . getLngt("Radiusbereichszuordnung") . "
" . getLngt("[Automatische Berechnung]") . "
" . getLngt("PLZ") . "" . getLngt("Bezirk/Stadt") . "" . getLngt("Nr.") . "
" . $selectRadiuses . "" . $buttonRadiusNew . "
" . $tmpArray[0] . "" . $tmpArray[1] . "" . $tmpArray[2] . "
\n"; endif; // * Zones an zone mappings * if ($customerId != "") : $output .= "
 \n"; // (Service) Zones if ($empIdRootAdmin == $emp_id || authCheckEmployeeRights($emp_id, "29")) : $output .= "\n"; $output .= "\n"; // $output .= "\n"; $output .= "\n"; $buttonZoneNew = defineButtonType10(getLngt("Neu"), "action_service_zone_new", "finishPage('insertNewServiceZone');", "100", "left", "0"); $output .= "\n"; $lineToggler = 0; for ($i = 0; $i < $lenServiceZones; $i++) : if ($lineToggler == 0) : $lineToggler = 1; else : $lineToggler = 0; endif; $cellColor = getListColor($i, $lineToggler); $tmpArray = $serviceZones[$i]; $output .= "\n"; $output .= ""; $output .= ""; $isChecked = ""; $output .= "\n"; $output .= "\n"; endfor; $output .= "
" . getLngt("Service-Zonen") . "
" . getLngt("[Manuelle Bearbeitung]") . "
" . getLngt("Nr.") . "" . getLngt("Zonenbezeichnung") . " 
 " . $buttonZoneNew . "
" . $tmpArray[1] . "" . $tmpArray[2] . "
\n"; $output .= "

\n"; endif; // Zone mappings $output .= "\n"; $output .= "\n"; $output .= "\n"; $output .= "\n"; $selectZones = ""; $buttonZoneMappingNew = defineButtonType10(getLngt("Neu"), "action_zonemapping_new", "finishPage('insertNewZoneMapping');", "100", "left", "0"); $output .= "\n"; $lineToggler = 0; for ($i = 0; $i < $lenServiceZoneMapping; $i++) : if ($lineToggler == 0) : $lineToggler = 1; else : $lineToggler = 0; endif; $cellColor = getListColor($i, $lineToggler); $tmpArray = $serviceZoneMapping[$i]; $output .= "\n"; $output .= ""; $output .= ""; $isChecked = ""; $output .= "\n"; $output .= ""; $output .= ""; $output .= "\n"; endfor; $output .= "
" . getLngt("Zonenzuordnung") . "
" . getLngt("[Import und manuelle Bearbeitung]") . "
" . getLngt("PLZ") . "" . getLngt("Nr.") . " " . getLngt("Express") . "" . getLngt("Zonenaufschlag") . "
" . $selectZones . "" . $buttonZoneMappingNew . "
" . $tmpArray[0] . "" . $tmpArray[1] . "" . formatOutput($tmpArray[4],"float_rounded_2") . " " . formatOutput($tmpArray[5],"float_rounded_2") . " 
\n"; endif; $output .= "
\n"; // Only for output $cmpId = getFieldValueFromId("customer", "cs_id", $customerId, "cmp_id"); $tmpFields = getFieldsValueFromId("company","cmp_id",$cmpId,array("cmp_comp","cmp_comp2")); $title = $tmpFields[0] . " " . $tmpFields[1]; $pageHeadline = "" . $pageTitle . "" . "     " . $tmpFields[0] . ($tmpFields[1] != "" ? " :: " . $tmpFields[1] : ""); // Administration of "delivery reasons" enabled? $parDeliveryReasonsEnabled = getParameterValue("0", "CUSTOMER_SERVICE_DELIVERY_REASONS", $hq_id); if ($parDeliveryReasonsEnabled == "") : $parDeliveryReasonsEnabled = getParameterValue("0", "CUSTOMER_SERVICE_DELIVERY_REASONS", "0"); endif; ?> <?php echo $pageTitle ?>
>
0) : echo htmlDivLineSpacer("5px", "", "left"); echo defineButtonType10(getLngt("Untersten Eintrag löschen"), "action_day_time_remove", "finishPage('day_time_remove');", "250", "", ""); endif; ?>
>

0) : echo htmlDivLineSpacer("5px", "", "left"); echo defineButtonType10(getLngt("Untersten Eintrag löschen"), "action_discount_mode_remove", "finishPage('discount_mode_remove');", "250", "", ""); endif; ?>
>
0) : echo htmlDivLineSpacer("5px", "", "left"); echo defineButtonType10(getLngt("Untersten Eintrag löschen"), "action_delivery_time_remove", "finishPage('delivery_time_remove');", "250", "", ""); endif; ?>
>
>
>
>
>
>