Merge branch 'Preorder/add-new-filter' into 'master'

reworked preorderlogistics

See merge request fronk/thetool!1635
This commit is contained in:
Luca Haid
2025-08-13 12:20:16 +00:00
3 changed files with 66 additions and 7 deletions

View File

@@ -32,6 +32,17 @@
<form method="get" action="<?=self::getUrl("Preorderlogistics")?>">
<div class="row mt-2">
<div class="col-sm-12 col-md-2">
<label class="form-label" for="filter_preordercampaign_id">Kampagne</label>
<select name="filter[preordercampaign_id]" id="filter_preordercampaign_id" class="form-control">
<option value="">Alle</option>
<?php foreach($my_campaigns as $c): ?>
<option value="<?=$c->id?>" <?=(isset($campaign) && $c->id == $campaign->id) ? "selected='selected'" : ""?>><?=$c->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_ucode">Bestellcode</label>
<input type="text" class="form-control" name="filter[ucode]" id="filter_ucode" value="<?=$filter['ucode'] ?? ""?>" />
@@ -59,6 +70,13 @@
<label class="form-label" for="filter_kunde">Kunde</label>
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=$filter['kunde'] ?? ""?>" />
</div>
<div class="col-sm-12 col-md-1">
<label class="form-label" for="filter_fcp">FCP</label>
<select name="filter[fcp][]" id="filter_fcp" multiple class="form-control">
<option value="">Kein FCP gefunden</option>
</select>
</div>
</div>
@@ -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");
})
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -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,

View File

@@ -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 = [];