Merge branch 'PreorderLogistics/add-multiple-campaigns' into 'master'
preorderlogistcs fix fcp filter and fix multiple campaigns See merge request fronk/thetool!1849
This commit is contained in:
@@ -756,7 +756,6 @@ class PreorderModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (array_key_exists("preordercampaign_id", $filter)) {
|
||||
$preordercampaign_id = $filter['preordercampaign_id'];
|
||||
if (is_numeric($preordercampaign_id)) {
|
||||
|
||||
@@ -55,8 +55,11 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
if (empty($filter['preordercampaign_id'])) {
|
||||
$filter['preordercampaign_id'] = $my_campaign_ids;
|
||||
} else {
|
||||
// Ensure the filtered campaign is one the user has access to
|
||||
if (!in_array($filter['preordercampaign_id'], $my_campaign_ids)) {
|
||||
// Ensure the filtered campaign is one the user has access to are arrays and if not allowed dont push it to the filter
|
||||
$preordercampaign_ids = is_array($filter['preordercampaign_id']) ? $filter['preordercampaign_id'] : [$filter['preordercampaign_id']];
|
||||
|
||||
$new_allowed_ids = array_intersect($preordercampaign_ids, $my_campaign_ids);
|
||||
if (empty($new_allowed_ids)) {
|
||||
self::returnJson(['rows' => [], 'pagination' => ['total_rows' => 0]]);
|
||||
return;
|
||||
}
|
||||
@@ -100,15 +103,22 @@ class PreorderlogisticsController extends mfBaseController {
|
||||
return;
|
||||
}
|
||||
|
||||
$apiUrl = self::getUrl("Preorder", "Api");
|
||||
$response = mf::get_url_content($apiUrl . "?do=getFCPsForCampaign&campaign_id=" . intval($this->request->campaign_id));
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (isset($data['status']) && $data['status'] == 'OK' && is_array($data['result'])) {
|
||||
self::returnJson($data['result']);
|
||||
} else {
|
||||
self::returnJson([]);
|
||||
if (is_array($this->request->campaign_id)) {
|
||||
if (count($this->request->campaign_id) !== 1) {
|
||||
self::returnJson([]);
|
||||
return;
|
||||
}
|
||||
$this->request->campaign_id = $this->request->campaign_id[0];
|
||||
}
|
||||
|
||||
|
||||
$campaign = new Preordercampaign($this->request->campaign_id);
|
||||
if (!$campaign->id) self::sendError("Kampagne nicht gefunden");
|
||||
|
||||
self::returnJson(array_map(
|
||||
fn($fcp) => ["real_id" => $fcp->id, "id" => $fcp->name ?? null, "text" => $fcp->name ?? null, 'lat' => $fcp->gps_lat ?? null, 'lng' => $fcp->gps_long ?? null],
|
||||
ADBRimoFcp::getAll(["netzgebiet_id" => intval($campaign->network->adb_netzgebiet_id)]) ?? []
|
||||
));
|
||||
}
|
||||
|
||||
protected function saveSentAction() {
|
||||
|
||||
@@ -6,4 +6,8 @@
|
||||
|
||||
.sent-checkbox-wrapper .fa-check {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.col-form-label {
|
||||
padding-top: 0 !important
|
||||
}
|
||||
@@ -6,7 +6,7 @@ Vue.component('preorder-logistics', {
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<tt-select label="Kampagne" :options="campaigns" v-model="filters.preordercampaign_id" sm/>
|
||||
<tt-select label="Kampagne" :options="campaigns" v-model="filters.preordercampaign_id" sm multiple/>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<tt-select label="FCP" :options="fcps" v-model="filters.fcp" sm multiple searchable/>
|
||||
@@ -76,6 +76,7 @@ Vue.component('preorder-logistics', {
|
||||
isPrinting: false,
|
||||
isExporting: false,
|
||||
isExportingAndMarking: false,
|
||||
lastFcpInfoTime: null,
|
||||
campaigns: [{value: '', text: 'Alle'}],
|
||||
fcps: [],
|
||||
sentStatusOptions: [
|
||||
@@ -123,6 +124,21 @@ Vue.component('preorder-logistics', {
|
||||
this.filters.fcp = [];
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(this.filters.preordercampaign_id) && this.filters.preordercampaign_id.length !== 1) {
|
||||
this.fcps = [];
|
||||
this.filters.fcp = [];
|
||||
const now = new Date().getTime();
|
||||
if (!this.lastFcpInfoTime || now - this.lastFcpInfoTime > 7000) {
|
||||
this.lastFcpInfoTime = now;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
window.notify('info', 'Bitte wählen Sie genau eine Kampagne aus, um die FCPs zu laden.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${window.TT_CONFIG.BASE_PATH}/Preorderlogistics/getFCPsForCampaign`, {
|
||||
params: {campaign_id: this.filters.preordercampaign_id}
|
||||
|
||||
Reference in New Issue
Block a user