reworked preorderlogistics

This commit is contained in:
2025-08-13 14:20:03 +02:00
parent 4259df5061
commit 6390628b19
3 changed files with 66 additions and 7 deletions
@@ -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"); ?>