Merge branch 'fronkdev' into 'master'
Preorder Api: Try next unit if no unit data was submitted See merge request fronk/thetool!133
This commit is contained in:
@@ -505,8 +505,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
if(count($unit_search)) {
|
||||
$update_unit = true;
|
||||
}
|
||||
|
||||
|
||||
} elseif($unit_search_count_without_stock > 0) {
|
||||
|
||||
//var_dump($unit_search);exit;
|
||||
if(array_key_exists("unit_string", $unit_search)) {
|
||||
$where .= " AND bezeichner LIKE '".$unit_search['unit_string']."'";
|
||||
@@ -529,7 +530,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
} else {
|
||||
$update_unit = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// if all unit values are empty try to find the unit with all empty values
|
||||
// failure is not an error, but must be checked by a human at some point
|
||||
$where = "hausnummer_id=".$address->hausnummer_id." AND (block = '' OR block IS NULL) AND (stiege = '' OR stiege IS NULL) AND (stock = '' OR stock IS NULL) AND (tuer = '' OR tuer IS NULL) AND (bezeichner = '' OR bezeichner IS NULL)";
|
||||
@@ -546,26 +549,44 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$sql = "SELECT * FROM view_wohneinheit WHERE $where";
|
||||
$this->log->debug($sql);
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
$unit = $this->db()->fetch_object($res);
|
||||
|
||||
$found_units_count = $this->db()->num_rows($res);
|
||||
if($found_units_count) {
|
||||
// check if unit has active preorder already and try next unit
|
||||
$existing_preorder = false;
|
||||
while($unit = $this->db()->fetch_object($res)) {
|
||||
// check if there is an existing preorder
|
||||
$existing_preorder = PreorderModel::getFirst(['adb_wohneinheit_id' => $unit->wohneinheit_id, 'deleted' => 0]);
|
||||
if(!$existing_preorder) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($existing_preorder && $this->exist_is_error && !$is_additional_order) {
|
||||
return mfResponse::Forbidden(['message' => "Für diese Wohneinheit liegt bereits eine Bestellung vor"]);
|
||||
}
|
||||
} else {
|
||||
// XXX - If there are no units without unit data maybe try finding a fitting unit without an order
|
||||
//$assign_unit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->exist_is_error && !$is_additional_order) {
|
||||
/*
|
||||
* check if there is an existing preorder for this unit already
|
||||
*/
|
||||
if($unit && $unit->wohneinheit_id) {
|
||||
$existing_preorder = PreorderModel::getFirst(['adb_wohneinheit_id' => $unit->wohneinheit_id, 'deleted' => 0]);
|
||||
if($existing_preorder) {
|
||||
|
||||
/*
|
||||
* check if there is an existing preorder for this unit already
|
||||
*/
|
||||
|
||||
if($unit && $unit->wohneinheit_id) {
|
||||
$existing_preorder = PreorderModel::getFirst(['adb_wohneinheit_id' => $unit->wohneinheit_id, 'deleted' => 0]);
|
||||
if($existing_preorder) {
|
||||
if($this->exist_is_error && !$is_additional_order) {
|
||||
return mfResponse::Forbidden(['message' => "Für diese Wohneinheit liegt bereits eine Bestellung vor"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$address_info = $this->db()->escape(trim($this->post['address_info']));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user