+
+
+
+
+
+
" />
@@ -59,6 +70,13 @@
" />
+
+
+
+
+
@@ -312,6 +330,45 @@
}
$("#csvExportAddressesAndMarkAsSent").on("click", csvExportAddressesAndMarkAsSent);
+ $(document).ready(function() {
+ const fcpSelect = $("#filter_fcp");
+ const campaignSelect = $("#filter_preordercampaign_id");
+ const apiUrl = "=self::getUrl("Preorder", "Api")?>";
+
+ fcpSelect.select2({ data: [], placeholder: "Bitte Kampagne auswählen", allowClear: true });
+
+ campaignSelect.on("change", function() {
+ const campaign_id = $(this).val();
+ if (!campaign_id) {
+ fcpSelect.empty().select2({ data: [], placeholder: "Bitte Kampagne auswählen", allowClear: true });
+ return;
+ }
+ $.get(apiUrl, { do: "getFCPsForCampaign", campaign_id: campaign_id }, (success) => {
+ let fcpData = [];
+ let opts = { data: [], placeholder: "Bitte Kampagne auswählen", allowClear: true };
+ if (success?.status === "OK" && Array.isArray(success.result)) {
+ fcpData = success.result;
+ fcpData.unshift({ id: "", text: "" });
+ fcpData.sort((a, b) => {
+ const aN = a.text.replace(/\D/g, ""), bN = b.text.replace(/\D/g, "");
+ return aN && bN ? parseInt(aN, 10) - parseInt(bN, 10) : a.text.localeCompare(b.text);
+ });
+ opts = { data: fcpData, placeholder: "", allowClear: true };
+ fcpSelect.empty().select2(opts);
+ const searchParams = new URLSearchParams(window.location.search);
+ const fcpValues = searchParams.getAll("filter[fcp][]");
+ if (fcpValues && fcpValues.length > 0) {
+ fcpSelect.val(fcpValues).trigger("change");
+ }
+ } else {
+ fcpSelect.empty().select2(opts);
+ }
+ }, "json").fail(() => {
+ fcpSelect.empty().select2({ data: [], placeholder: "Fehler", allowClear: true });
+ });
+ });
+ campaignSelect.trigger("change");
+ })
diff --git a/application/ADBRimoFcp/ADBRimoFcpController.php b/application/ADBRimoFcp/ADBRimoFcpController.php
index 8a8828081..9c4804714 100644
--- a/application/ADBRimoFcp/ADBRimoFcpController.php
+++ b/application/ADBRimoFcp/ADBRimoFcpController.php
@@ -41,6 +41,7 @@ class ADBRimoFcpController extends TTCrud {
$now = date('U');
foreach ($fcpList as $fcpIn) {
+ $localNetworkAreaId = $networkAreaId;
$rimoId = $fcpIn['ExternalID'] ?? $fcpIn['External ID'] ?? $fcpIn['Externe ID'] ?? null;
if ($rimoId === null) continue;
if (!is_numeric($networkAreaId)) {
@@ -49,14 +50,14 @@ class ADBRimoFcpController extends TTCrud {
]);
if ($netzgebiet) {
- $networkAreaId = $netzgebiet->id;
+ $localNetworkAreaId = $netzgebiet->id;
} else {
continue;
}
}
$data = [
- 'netzgebiet_id' => $networkAreaId,
+ 'netzgebiet_id' => $localNetworkAreaId,
'name' => $fcpIn['Name'] ?? $fcpIn['Name/ID'] ?? null,
'rimo_id' => $rimoId,
'label' => $fcpIn['User label'] ?? $fcpIn['Bezeichnung'] ?? null,
diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php
index 9a11fefff..581175fe6 100644
--- a/application/Preorder/PreorderController.php
+++ b/application/Preorder/PreorderController.php
@@ -9,8 +9,12 @@ class PreorderController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me", $me);
- if(!$me->is(["Admin", "netowner", "salespartner", "preorderfront"])) {
- $this->redirect("Dashboard");
+ $isApiWhitelist = (isset($_GET['do']) && $_GET['do'] === 'getFCPsForCampaign' && $this->action === 'Api');
+
+ if (!$me->is(["Admin", "netowner", "salespartner", "preorderfront"])) {
+ if (!$isApiWhitelist) {
+ $this->redirect("Dashboard");
+ }
}
}
@@ -1034,9 +1038,6 @@ class PreorderController extends mfBaseController {
}
protected function apiAction() {
- if(!$this->me->is(["Admin", "netowner", "salespartner", "preorderfront"])) {
- $this->redirect("Dashboard");
- }
$do = $this->request->do;
$data = [];