Fixed not finding unit sometimes in PreorderApi/submitPreorder

This commit is contained in:
Frank Schubert
2023-10-03 15:19:44 +02:00
parent a6aa87a5ee
commit acee68c6c3
4 changed files with 15 additions and 10 deletions

View File

@@ -9,7 +9,7 @@ class AddressDBController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me",$me);
if(!$me->is(["Admin", "netowner"])) {
if(!$me->is(["Admin", "netowner"]) && !$me->can("Preorder")) {
$this->redirect("Dashboard");
}
}
@@ -438,7 +438,7 @@ class AddressDBController extends mfBaseController {
}
protected function apiAction() {
if(!$this->me->is(["Admin","netowner"])) {
if(!$this->me->is(["Admin","netowner"]) && !$this->me->can("Preorder")) {
$this->redirect("Dashboard");
}
$do = $this->request->do;

View File

@@ -411,7 +411,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
if($field == "ortschaft" || $field == "gemeinde") continue;
$where .= " AND `$field` = '$value'";
}
// filter salesclusters
if(count($this->filter_salescluster_ids)) {
$where .= " AND netzgebiet_id IN (".implode(',', $this->filter_salescluster_ids).")";
@@ -753,9 +753,8 @@ class PreorderApicontroller extends mfBaseApicontroller {
} else {
// else get available units with no unit data, so we can update it
$exclude_wohneinheit_ids = [];
$preorders_in_hausnummer = PreorderModel::search(['adb_hausnummer_id' => $address->hausnummer_id]);
$preorders_in_hausnummer = PreorderModel::search(['adb_hausnummer_id' => $address->hausnummer_id, "deleted" => 0]);
if(count($preorders_in_hausnummer)) {
foreach($preorders_in_hausnummer as $pih) {
if($pih->adb_wohneinheit_id) {
$exclude_wohneinheit_ids[] = $pih->adb_wohneinheit_id;
@@ -770,7 +769,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
$where .= " AND ( stock = '' OR stock IS NULL)";
$where .= " AND ( tuer = '' OR tuer IS NULL)";
$where .= " AND ( bezeichner = '' OR bezeichner IS NULL)";
if(count($exclude_wohneinheit_ids)) {
$where .= " AND wohneinheit_id NOT IN (". implode(",",$exclude_wohneinheit_ids).")";
}
@@ -780,7 +779,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
if(!$this->db()->num_rows($res)) {
return mfResponse::Forbidden(['message' => "Keine Wohneinheiten verfügbar"]);
}
$unit_row = $this->db()->fetch_object($res);
$unit = new ADBWohneinheit($unit_row->wohneinheit_id);
}

View File

@@ -1,4 +1,4 @@
<?php
x<?php
/**
* Description of UserController
@@ -205,9 +205,14 @@ class UserController extends mfBaseController
if (is_array($r->preorder_networks) && count($r->preorder_networks)) {
$pn->value(json_encode($r->preorder_networks));
$pn->save();
$user->permissions->canPreorder = true;
} else {
$pn->delete();
}
//XXX - set all can permissions true
}
$this->layout()->setFlash("Benutzer gespeichert.", "success");

View File

@@ -18,6 +18,7 @@ define("INTERNAL_USER_USERNAME", $me->username);
$ignore_preorders = [];
$campaign_prem_nord = 5;
$campaign_gross_st_florian = 7;
$same_unit_count = 0;
$missing_units = [];
@@ -25,7 +26,7 @@ $missing_doors = [];
$total = 0;
$c = 0;
foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaign_prem_nord, "connection_count" => 2]) as $preorder) {
foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaign_gross_st_florian, "connection_count" => 2]) as $preorder) {
// check if we have enough units with extref
$wohneinheiten = ADBWohneinheitModel::search(["hausnummer_id" => $preorder->adb_hausnummer_id]);
$unit_count = count($wohneinheiten);
@@ -119,4 +120,4 @@ foreach($missing_doors as $md) {
echo "\n";
}
echo "Processed $total, created $c preorders\n";
echo "Processed $total, created $c preorders\n";