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() {
|
||||
|
||||
Reference in New Issue
Block a user