Fixed not finding unit sometimes in PreorderApi/submitPreorder
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user